1 master11创建本地镜像仓库
[root@master11 ~]# docker run -d -p 5000:5000 --restart=always --name registry registry:2
Unable to find image 'registry:2' locally
2: Pulling from library/registry
79e9f2f55bf5: Pull complete
0d96da54f60b: Pull complete
5b27040df4a2: Pull complete
e2ead8259a04: Pull complete
3790aef225b9: Pull complete
Digest: sha256:169211e20e2f2d5d115674681eb79d21a217b296b43374b8e39f97fcf866b375
Status: Downloaded newer image for registry:2
4690e99a111cae7934202047ae9591af33c8cb46bc970af698e02414fe3d09d0
#查看
[root@master11 ~]# docker ps -a| grep registry:2
4690e99a111c registry:2 "/entrypoint.sh /etc…" About a minute ago Up About a minute 0.0.0.0:5000->5000/tcp, :::5000->5000/tcp registry
2 节点配置
vi /etc/docker/daemon.json
增加
"insecure-registries":["192.168.50.11:5000"]
#重新启动服务
systemctl restart docker
3 拉取镜像
docker pull tencentci/discuz
#查看
[root@master11 ~]# docker images|grep discuz
tencentci/discuz latest caba9d3ea6d8 4 months ago 574MB
#mysql
docker pull mysql
#查看
[root@master11 ~]# docker images|grep mysql
mysql latest 3218b38490ce 2 years ago 516MB
4 构建容器
docker run --name discuz -d -p 9611:80 -p 9612:443 tencentci/discuz:latest
#查看
[root@master11 ~]# docker ps -a| grep discuz
6ac200af7c42 tencentci/discuz:latest "docker-php-entrypoi…" 4 seconds ago Up 3 seconds 0.0.0.0:9611->80/tcp, :::9611->80/tcp, 0.0.0.0:9612->443/tcp, :::9612->443/tcp discuz
#mysql
docker run -d -P --name mysql -v /data/mysql:/var/lib/mysql -e MYSQL_ROOT_PASSWORD='密码' mysql:latest
#
[root@master11 ~]# docker ps -a| grep mysql
a73c2a16eb0c mysql:latest "docker-entrypoint.s…" 3 minutes ago Up 3 minutes 0.0.0.0:32769->3306/tcp, :::32769->3306/tcp, 0.0.0.0:32768->33060/tcp, :::32768->33060/tcp mysql
#docker时间相差8个小时,由于时区设置不正确导致的
[root@master11 ~]# docker exec -it discuz bash
root@6ac200af7c42:/var/www/html# date
Tue May 21 07:45:02 UTC 2024
root@6ac200af7c42:/var/www/html# date -R
Tue, 21 May 2024 07:45:06 +0000
root@6ac200af7c42:/var/www/html# ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
root@6ac200af7c42:/var/www/html# date -R
Tue, 21 May 2024 15:45:14 +0800
#mysql
[root@master11 ~]# docker exec -it mysql bash
root@a73c2a16eb0c:/# date -R
Tue, 21 May 2024 07:46:30 +0000
root@a73c2a16eb0c:/# ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
root@a73c2a16eb0c:/# date -R
Tue, 21 May 2024 15:46:36 +0800
5 配置数据库
docker exec -it mysql /bin/bash
#创建数据库
create database discuz charset utf8;
6 安装Discuz!X3.5(全新独立安装)
在浏览器中访问 http://你的网站/install/ 开始全新安装
7 打包discuz镜像,推送到本地私有仓库
#discuz容器保存为一个新的镜像
docker commit discuz 192.168.50.11:5000/discuz:x3.5
#查看
[root@master11 ~]# docker images|grep discuz
192.168.50.11:5000/discuz x3.5 2835ba731e97 24 seconds ago 575MB
tencentci/discuz latest caba9d3ea6d8 4 months ago 574MB
#推送报错
[root@master11 ~]# docker push 192.168.50.11:5000/discuz:x3.5
The push refers to repository [192.168.50.11:5000/discuz]
Get "https://192.168.50.11:5000/v2/": http: server gave HTTP response to HTTPS client
#
vim /etc/docker/daemon.json
"insecure-registries":["192.168.50.11:5000"]
#重新启动服务
systemctl restart docker
[root@master11 ~]# docker push 192.168.50.11:5000/discuz:x3.5
The push refers to repository [192.168.50.11:5000/discuz]
425b7adba1a0: Pushed
ade553ab1f0e: Pushed
5665aca10e81: Pushed
e35c78742574: Pushed
45fe1d6a2061: Pushed
024366104021: Pushed
df4196a4a45c: Pushed
a50f767c8ac6: Pushed
8b3e67ab0bd0: Pushed
8bf5266e2217: Pushed
240c853402b6: Pushed
17398fc120fa: Pushed
cfa11f06a213: Pushed
8f477d20e632: Pushed
658dc28b7c93: Pushed
89a3f58688e1: Pushed
3af749400b4a: Pushed
e1bbcf243d0e: Pushed
x3.5: digest: sha256:7fec4496c5cf54f5f4eeccb70d9ca938684ff00a8d75cc57d60b70da0b635437 size: 4088
#查看本地仓库镜像列表
[root@master11 data]# curl -X GET http://192.168.50.11:5000/v2/_catalog
{"repositories":["discuz"]}
5 节点测试本地私有仓库
[root@slave12 ~]# curl -X GET http://192.168.50.11:5000/v2/_catalog
{"repositories":["discuz"]}
下一篇,K8s批量集群部署Discuz.欢迎一起交流!