此文是构建本地Docker Registry的过程和语句
事情说明
此文使用的是oracle virtualbox创建的虚拟机环境。
网络使用NAT和Host-Only配置。Host-Only的IP段为192.168.56.*。
(关于Host-Only配置,请参考https://blog.csdn.net/engchina/article/details/82077666)
虚拟机的操作系统是oracle linux 7.5。IP为192.168.56.200。
配置
启动registry(使用普通用户)。
docker run -d --name docker-hub --restart=always -v /var/lib/docker-hub/registry:/var/lib/registry -p 5000:5000 registry:2.6.2
修改docker的设置(使用root用户)。
vi /usr/lib/systemd/system/docker.service
修改ExecStart,加上--insecure-registry的本地ip和port。
ExecStart=/usr/bin/dockerd --insecure-registry 192.168.56.200:5000
测速(使用普通用户)
从docker hub上取得hello-world,传到本地docker registry,然后执行。
(tag默认是latest,如果tag不是latest,请在images后面加上tag。例如:mysql:5.7.23)
docker pull hello-world
docker tag hello-world 192.168.56.200:5000/hello-world
docker push 192.168.56.200:5000/hello-world
docker run 192.168.56.200:5000/hello-world
通过api查看本地registry的catalog
curl 192.168.56.200:5000/v2/_catalog
通过api查看本地registry的某个image的tag
格式为curl 192.168.56.200:5000/v2/<image name>/tags/list
curl 192.168.56.200:5000/v2/hello-world/tags/list