Docker搭建私有仓库并上传镜像到私有仓库

 第一步:获取registry镜像

[root@localhost ~]# docker pull registry
Using default tag: latest
latest: Pulling from library/registry
c87736221ed0: Pull complete 
1cc8e0bb44df: Pull complete 
54d33bcb37f5: Pull complete 
e8afc091c171: Pull complete 
b4541f6d3db6: Pull complete 
Digest: sha256:f87f2b82b4873e0651f928dcde9556008314543bd863b3f7e5e8d03b04e117f7
Status: Downloaded newer image for registry:latest

第二步:启动一个容器

[root@localhost ~]# docker run --name registry -p 5000:5000 -d registry
e18fbeadc2af07b7d57801a67aeccbc29330625ed2f8f2bf4515d7355906a46e

第三步:配置registry服务是安全可信赖的,vi /etc/docker/daemon.json

{
"registry-mirrors": ["http://hub-mirror.c.163.com"],
"insecure-registries":["192.168.10.128:5000"]
 }

第四步:重启docker和registry

[root@localhost ~]# systemctl restart docker
[root@localhost ~]# docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
[root@localhost ~]# docker start registry 
registry

 第五步:通过docker tag将镜像标志为要推送到私有仓库的镜像

[root@localhost ~]# docker tag mynginx_backup 192.168.10.128:5000/mynginx_backu
[root@localhost ~]# docker images
REPOSITORY                          TAG                 IMAGE ID            CREATED             SIZE
192.168.10.128:5000/mynginx_backu   latest              a6ca067596a2        About an hour ago   109MB
mynginx_backup                      latest              a6ca067596a2        About an hour ago   109MB

第六步:运行docker push将192.168.10.128:5000/mynginx_backu镜像push到我们的私有仓库中

[root@localhost ~]# docker push 192.168.10.128:5000/mynginx_backu
The push refers to repository [192.168.10.128:5000/mynginx_backu]
ea4399e4dbe6: Pushed 
ea06a73e56fc: Pushed 
22c458a3ff08: Pushed 
6270adb5794c: Pushed 
latest: digest: sha256:726fd06e4d816675d3cf548bc8c47afa1778b3b3ea3b249b8e1ad70117914627 size: 1155

第七步:浏览器输入地址查看结果

第八步:将本地的镜像删除

[root@localhost ~]# docker rmi 192.168.10.128:5000/mynginx_backu:latest 
Untagged: 192.168.10.128:5000/mynginx_backu:latest
Untagged: 192.168.10.128:5000/mynginx_backu@sha256:726fd06e4d816675d3cf548bc8c47afa1778b3b3ea3b249b8e1ad70117914627
[root@localhost ~]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
mynginx_backup      latest              a6ca067596a2        About an hour ago   109MB

第九步:使用docker pull从我们的私有仓库中获取192.168.10.128:5000/mynginx_backu镜像

[root@localhost ~]# docker pull 192.168.10.128:5000/mynginx_backu
Using default tag: latest
latest: Pulling from mynginx_backu
Digest: sha256:726fd06e4d816675d3cf548bc8c47afa1778b3b3ea3b249b8e1ad70117914627
Status: Downloaded newer image for 192.168.10.128:5000/mynginx_backu:latest
[root@localhost ~]# docker images
REPOSITORY                          TAG                 IMAGE ID            CREATED             SIZE
192.168.10.128:5000/mynginx_backu   latest              a6ca067596a2        About an hour ago   109MB
mynginx_backup                      latest              a6ca067596a2        About an hour ago   109MB

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值