偷偷学 Docker 系列 | 建立属于你自己的私有仓库

①下载 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 ~]# docker images 
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 ~]# docker rmi 192.168.126.17:5000/nginx:latest nginx:latest 
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 ~]# docker images 
REPOSITORY   TAG       IMAGE ID       CREATED        SIZE
registry     latest    678dfa38fcfa   3 months ago   26.2MB
[root@localhost ~]# docker pull 192.168.126.17:5000/nginx
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 ~]# docker images 
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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Xucf1

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值