CentOS搭建Docker Hub私有仓库

docker pull registry
拉取registry镜像

docker images
查看镜像

docker run -d -p 5000:5000 -v /opt/data/registry:/tmp/registry registry
启动容器

Registry服务默认将仓库存放于容器内的/tmp/registry目录下,
这样如果容器被删除,
则存放于容器中的镜像也会丢失,
所以我们一般情况下会指定本地一个目录挂载到容器内的/tmp/registry下

sudo docker ps -a
查看容器

firewall-cmd --zone=public --permanent --add-port=5000/tcp
firewall-cmd --reload
开启防火墙5000端口

访问
http://192.168.1.6:5000/v2/

docker tag hello-world localhost:5000/2018
把hello-world镜像的标签修改为localhost:5000/2018

docker push localhost:5000/2018
把localhost:5000/2018镜像推送到私有仓库

访问
http://192.168.1.6:5000/v2/_catalog


docker rmi hello-world localhost:5000/2018
把本地的hello-world与localhost:5000/2018这2个镜像都删掉

docker pull localhost:5000/2018
从私有仓库里拉取localhost:5000/2018镜像

docker images
此时再查看镜像

猜你喜欢

转载自www.cnblogs.com/yjlch1016/p/9028811.html