1、拉取 registry
docker pull registry:2
2、启动
docker run --name registry \
-p 5000:5000 \
-v /opt/registry:/var/lib/registry \
--restart=always \
-d registry:2
3、配置
vim /etc/docker/daemon.json
# 结果
{
"registry-mirrors": ["http://hub-mirror.c.163.com"],
"insecure-registries":["192.168.2.104:5000"]
}
4、重启
systemctl restart docker
4、测试
curl http://192.168.2.104:5000/v2/_catalog
# 结果
{"repositories":[]}
5、拉取 nginx 镜像
docker pull nginx
docker images
# 显示
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/nginx latest 0901fa9da894 5 days ago 132 MB
docker.io/registry 2 2d4f4b5309b1 3 weeks ago 26.2 MB
6、标记 nginx 镜像为私有仓库的镜像
docker tag nginx:latest 192.168.2.104:5000/nginx:v1
7、查看 镜象
[root@kvm104 ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/registry 2 2d4f4b5309b1 2 weeks ago 26.2 MB
192.168.2.104:5000/nginx v1 2622e6cca7eb 3 weeks ago 132 MB
docker.io/nginx latest 2622e6cca7eb 3 weeks ago 132 MB
8、启动私有仓库
docker start registry
9、上传镜象
docker push 192.168.2.104:5000/nginx
10、查看
curl http://192.168.2.104:5000/v2/_catalog
# 结果
{"repositories":["nginx"]}
11、找一台虚拟 拉取镜象
docker pull 192.168.2.104:5000/nginx:v1