主节点:10.24.2.30
从节点:10.24.2.31
主节点配置:
yum -y install docker
systemctl restart docker
docker push registry
docker run -d -v /opt/registry:/var/lib/registry -p 5000:5000 --restart=always --name registry registry
//-v 参数 将主机的/opt/registry与仓库的/var/lib/registry作挂载
docker ps 查看运行情况
配置私有仓库
cat>/etc/docker/daemon.json<<EOF
{
"registry-mirrors":["https://registry.docker-cn.com","https://docker.mirrors.ustc.edu.cn","https://tnxkcso1.mirrors.aliyuncs.com"],
"insecure-registries":["10.24.2.30:5000"]
}
EOF
systemctl restart docker
docker pull nginx 获取镜像
docker tag nginx:latest 10.24.2.30:5000/nginx:latest 打标签
docker push 10.24.2.30:5000/nginx:latest 向自己的私有仓库上传镜像
从节点:配置客户端私有仓库
yum -y install docker
cat>/etc/docker/daemon.json<<EOF
{
"insecure-registries":["10.24.2.30:5000"]
}
EOF
systemctl restart docker
docker pull 10.24.2.30:5000/nginx:latest 拉取自己配置的私有仓库上的镜像