搭建docker本地仓库

1、修改内核转发(每台机器都要执行,或者将文件直接复制到对方机器)

echo "net.ipv4.ip_forward = 1" >>/etc/sysctl.conf  && sysctl -p

2、下载仓库项目镜像

docker pull registry:2

3、启动仓库并映射工作目录

mkdir -p /opt/data/registry
docker run -itd -p 5000:5000 \
  --restart always \
  -v /opt/data/registry/:/var/lib/registry \
  --name registry registry:2

4、修改docker启动项,告诉主机私有仓库的地址(每台机器都需要执行)

sed -i "s#ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock#ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock --insecure-registry 192.168.10.190:5000#g" /usr/lib/systemd/system/docker.service
systemctl daemon-reload && systemctl restart docker && docker info

5、给现有镜像打tag然后上传到镜像仓

docker tag httpd:latest 192.168.10.190:5000/httpd

docker tag busybox:1.28.4 192.168.10.190:5000/busybox:1.28.4

docker tag centos:7 192.168.10.190:5000/centos:7

 

6、上传镜像到私有仓库

docker push 192.168.10.190:5000/httpd
docker push 192.168.10.190:5000/centos:7
docker push 192.168.10.190:5000/busybox:1.28.4

7、在其他节点上下载镜像

docker pull 192.168.10.190:5000/centos:7
docker pull 192.168.10.190:5000/busybox:1.28.4

 

8、docker 部署可视化 UI页面,实时查看节点状态

下载镜像后需要传到私有仓库中

docker pull dockersamples/visualizer
docker tag dockersamples/visualizer:latest 192.168.10.190:5000/visualizer
docker push 192.168.10.190:5000/visualizer

启动

docker run -itd -p 8888:8080 \
  --restart=always \
  -e HOST=192.168.10.190 \
  -e PORT=8080 -v /var/run/docker.sock:/var/run/docker.sock \
  --name visualizer 192.168.10.190:5000/visualizer

 

到此部署完成

posted @ 2020-10-03 16:21  缺个好听的昵称  阅读(786)  评论(0编辑  收藏  举报