docker私有仓库regidtry

下载registry和nignx

//
[root@docker ~]# docker pull registry 
[root@docker ~]# docker pull nginx 

在这里插入图片描述

docker引擎终端设置仓库地址

//
[root@localhost ~]# cd /etc/docker
[root@localhost docker]# ls
daemon.json  key.json
[root@localhost docker]# vim daemon.json

{
  "insecure-registries": ["192.168.142.141:5000"],
  "registry-mirrors": ["https://m1aaxlq9.mirror.aliyuncs.com"]
}
[root@localhost docker]# systemctl restart docker

宿主机的 /data/registry 自动创建挂载容器中的 /tmp/registry

//
[root@localhost ~]# docker run -d -p 5000:5000 -v /data/registry:/tmp/registry registry
a663dac65316e6cc6b1b9885560492cf2fe0a5da0529bcc923f28543202b8b3e

打标签

//
[root@localhost ~]# docker tag nginx:latest 192.168.142.141:5000/nginx

在这里插入图片描述

上传镜像到私有仓库

//
[root@localhost ~]# docker push 192.168.142.141:5000/nginx

获取私有仓库镜像列表

//
[root@localhost ~]# curl -XGET http://192.168.142.141:5000/v2/_catalog

在这里插入图片描述再上传centos:7

//
[root@localhost ~]# docker tag centos:7 192.168.142.141:5000/centos:7
[root@localhost ~]# docker push 192.168.142.141:5000/centos:7
The push refers to repository [192.168.142.141:5000/centos]
174f56854903: Pushed 
7: digest: sha256:e4ca2ed0202e76be184e75fb26d14bf974193579039d5573fb2348664deef76e size: 529
[root@localhost ~]# curl -XGET http://192.168.142.141:5000/v2/_catalog
{"repositories":["centos","nginx"]}

先删除本地镜像

//
[root@localhost ~]# docker images
REPOSITORY                    TAG       IMAGE ID       CREATED         SIZE
192.168.142.141:5000/nginx    latest    ad4c705f24d3   4 days ago      133MB
nginx                         latest    ad4c705f24d3   4 days ago      133MB
registry                      latest    b2cb11db9d3d   13 days ago     26.2MB
192.168.142.141:5000/centos   7         8652b9f0cb4c   10 months ago   204MB
centos                        7         8652b9f0cb4c   10 months ago   204MB

[root@localhost ~]# docker rmi 192.168.142.141:5000/nginx

[root@localhost ~]# docker rmi 192.168.142.141:5000/centos:7

[root@localhost ~]# docker images
REPOSITORY   TAG       IMAGE ID       CREATED         SIZE
nginx        latest    ad4c705f24d3   4 days ago      133MB
registry     latest    b2cb11db9d3d   13 days ago     26.2MB
centos       7         8652b9f0cb4c   10 months ago   204MB

测试能否从私有仓库下载镜像

//
[root@localhost ~]# docker pull 192.168.142.141:5000/nginx
[root@localhost ~]# docker pull 192.168.142.141:5000/centos:7

[root@localhost ~]# docker images
REPOSITORY                    TAG       IMAGE ID       CREATED         SIZE
192.168.142.141:5000/nginx    latest    ad4c705f24d3   4 days ago      133MB
nginx                         latest    ad4c705f24d3   4 days ago      133MB
registry                      latest    b2cb11db9d3d   13 days ago     26.2MB
192.168.142.141:5000/centos   7         8652b9f0cb4c   10 months ago   204MB
centos                        7         8652b9f0cb4c   10 months ago   204MB

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值