libra0 2020-05-12
有一个集群, 里面有三台服务器
master: 192.168.1.106
nodes1: 192.168.1.104
nodes2: 192.168.1.105
操作系统: 使用的MacOS, windows同样有效
选择将nodes1作为镜像仓库.
docker pull registry
docker run -p 5000:5000 -v /home/registry_images:/var/lib/registry -d registry
这里将registry挂载到了本地home目录, 避免docker重启后, 镜像丢失
/etc/docker/daemon.json
{ "insecure-registries":["192.168.1.104:5000"], //修改为registry所在容器的宿主机 "registry-mirrors": ["https://w52p8twk.mirror.aliyuncs.com"] }
"insecure-registries": 含义是, 192.168.1.104不是一个安全的http请求, 但请信任这个仓库地址.
我的registry在node节点上, node的ip是192.168.1.104
systemctl daemon-reload systemctl restart docker
领取nginx镜像 docker pull nginx 改名 docker tag nginx 192.168.1.104:5000/nginx:test
尝试把 192.168.1.104:5000/nginx:test上传到我们的Registry仓库
docker push 192.168.1.104:5000/nginx:test
可以成功push, 说明我们的仓库是创建成功了.
{ "insecure-registries":["192.168.1.104:5000"], "registry-mirrors": ["https://w52p8twk.mirror.aliyuncs.com"] }
重启docker
systemctl daemon-reload systemctl restart docker