①下载 registry 镜像
docker pull registry
②指定镜像仓库地址
vim /etc/docker/daemon.json
{
"insecure-registries": ["192.168.126.17:5000"], '//添加此段,本机IP地址'
"registry-mirrors": ["https://q0kfjn11.mirror.aliyuncs.com"]
}
--
systemctl restart docker.service
③创建 registry 容器并开放端口
docker create -it registry /bin/bash
docker start 7c2612bf42a9
docker run -d -p 5000:5000 -v /data/registry:/tmp/registry registry
'//-p指定端口,一内一外;-v表示挂载,前者是宿主机,后者是容器'
④给镜像打标签后上传
docker tag nginx:latest 192.168.126.17:5000/nginx
docker push 192.168.126.17:5000/nginx
⑤获取私有仓库列表查看是否上传成功
curl -XGET http://192.168.126.17:5000/v2/_catalog
'//若成功会返回以下值'
{"repositories":["nginx"]}
⑥从私有仓库下载镜像
[root@localhost ~]
REPOSITORY TAG IMAGE ID CREATED SIZE
192.168.126.17:5000/nginx latest f6d0b4767a6c 2 months ago 133MB
nginx latest f6d0b4767a6c 2 months ago 133MB
registry latest 678dfa38fcfa 3 months ago 26.2MB
[root@localhost ~]
Untagged: 192.168.126.17:5000/nginx:latest
Untagged: 192.168.126.17:5000/nginx@sha256:0b159cd1ee1203dad901967ac55eee18c24da84ba3be384690304be93538bea8
Untagged: nginx:latest
Untagged: nginx@sha256:10b8cc432d56da8b61b070f4c7d2543a9ed17c2b23010b43af434fd40e2ca4aa
Deleted: sha256:f6d0b4767a6c466c178bf718f99bea0d3742b26679081e52dbf8e0c7c4c42d74
Deleted: sha256:4dfe71c4470c5920135f00af483556b09911b72547113512d36dc29bfc5f7445
Deleted: sha256:3c90a0917c79b758d74b7040f62d17a7680cd14077f734330b1994a2985283b8
Deleted: sha256:a1c538085c6f891424160d8db120ea093d4dda393e94cd4713e3fff3c82299b5
Deleted: sha256:a3ee2510dcf02c980d7aff635909612006fd1662084d6225e52e769b984abeb5
Deleted: sha256:cb42413394c4059335228c137fe884ff3ab8946a014014309676c25e3ac86864
[root@localhost ~]
REPOSITORY TAG IMAGE ID CREATED SIZE
registry latest 678dfa38fcfa 3 months ago 26.2MB
[root@localhost ~]
Using default tag: latest
latest: Pulling from nginx
a076a628af6f: Pull complete
0732ab25fa22: Pull complete
d7f36f6fe38f: Pull complete
f72584a26f32: Pull complete
7125e4df9063: Pull complete
Digest: sha256:0b159cd1ee1203dad901967ac55eee18c24da84ba3be384690304be93538bea8
Status: Downloaded newer image for 192.168.126.17:5000/nginx:latest
192.168.126.17:5000/nginx:latest
[root@localhost ~]
REPOSITORY TAG IMAGE ID CREATED SIZE
192.168.126.17:5000/nginx latest f6d0b4767a6c 2 months ago 133MB
registry latest 678dfa38fcfa 3 months ago 26.2MB