1、安装docker
yum install -y yum-utils
#官方源
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
#阿里云加速源
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum install docker-ce docker-ce-cli containerd.io
2、配置docker网段和加速源
/etc/docker/daemon.json
{
"bip": "192.168.120.1/24",
"registry-mirrors": [
"https://docker.1panel.live"
]
}
3、启动服务
systemctl enable --now docker
4、创建docker-compose.ymldocker-compose.yml
version: "3.3"
services:
db:
image: mariadb:10.8.2
container_name: spug-db
restart: always
command: --port 3306 --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
volumes:
- /data/spug/mysql:/var/lib/mysql
environment:
- MYSQL_DATABASE=spug
- MYSQL_USER=spug
- MYSQL_PASSWORD=spug.cc
- MYSQL_ROOT_PASSWORD=spug.cc
spug:
image: openspug/spug-service
container_name: spug
privileged: true
restart: always
volumes:
- /data/spug/service:/data/spug
- /data/spug/repos:/data/repos
ports:
# 如果80端口被占用可替换为其他端口,例如: - "8000:80"
- "80:80"
environment:
- MYSQL_DATABASE=spug
- MYSQL_USER=spug
- MYSQL_PASSWORD=spug.cc
- MYSQL_HOST=db
- MYSQL_PORT=3306
depends_on:
- db
5、启动容器
docker compose up -d
6、初始化
以下操作会创建一个用户名为 admin 密码为 spug.cc 的管理员账户,可自行替换管理员账户/密码。
docker exec spug init_spug admin spug.cc
7、访问测试
在浏览器中输入 http://ip:80 访问。
8、开始使用
评论