五、Docker构建私有registry

1.启动registry

docker run -d -p 5000:5000 --restart=always --name registry -v /opt/registry:/var/lib/registry  registry

2.修改配置文件

vim /etc/docker/daemon.json
{ "registry-mirrors": ["https://68rmyzg7.mirror.aliyuncs.com"], "insecure-registries": ["10.0.0.100:5000"] } [root@docker docker]# systemctl restart docker

3.制作本地镜像并push

[root@docker ~]# docker tag nginx 10.0.0.100:5000/maxzhu/nginx:v1
[root@docker ~]# docker images
[root@docker ~]# docker push 10.0.0.100:5000/maxzhu/nginx:v1

4. 异地进行pull镜像

[root@docker ~]# docker pull  10.0.0.100:5000/maxzhu/nginx:v1

5.本地仓库加安全认证并重新启动

生成密码:
yum install httpd-tools -y
mkdir /opt/registry-auth/ -p
htpasswd  -Bbn oldguo 123 > /opt/registry-auth/htpasswd
docker rm -f `docker ps -aq`
docker run -d -p 5000:5000 -v /opt/registry-auth/:/auth/ -v /opt/registry:/var/lib/registry  --name register-auth -e "REGISTRY_AUTH=htpasswd" -e "REGISTRY_AUTH_HTPASSWD_REALM=Registry Realm" -e "REGISTRY_AUTH_HTPASSWD_PATH=/auth/htpasswd" registry 

 

  

posted @ 2020-05-14 17:45  zhuguoqing  阅读(263)  评论(0编辑  收藏  举报