docker仓库管理

下载registry镜像:

[root@localhost ~]# docker pull registry
Using default tag: latest
latest: Pulling from library/registry
d6a5679aa3cf: Pull complete
ad0eac849f8f: Pull complete
2261ba058a15: Pull complete
f296fda86f10: Pull complete
bcd4a541795b: Pull complete
Digest: sha256:5a156ff125e5a12ac7fdec2b90b7e2ae5120fa249cf62248337b6d04abc574c8
Status: Downloaded newer image for registry:latest

启动容器:

[root@localhost ~]# docker run -d -p 5000:5000 registry    //以registry镜像启动容器,-p会把容器的端口映射到宿主机上,:左边为宿主机监听端口,:右边为容器监听端口
f81917ea6f5da83cf8ba7c37e61e997cb0fe98f7be6f198b0a9f0a4f0e33b76c

将镜像上传到私有仓库:

[root@localhost ~]# docker tag centos6 192.168.137.20:5000/centos6
[root@localhost ~]# docker images
REPOSITORY                    TAG                 IMAGE ID            CREATED             SIZE
192.168.137.20:5000/centos6   latest              6fab0d69e1b3        22 hours ago        512MB
centos6                       latest              6fab0d69e1b3        22 hours ago        512MB
centos_with_net               latest              c12f48252a86        41 hours ago        300MB
centos                        latest              75835a67d134        3 weeks ago         200MB
test111                       171104              75835a67d134        3 weeks ago         200MB
zhangfei_centos               latest              75835a67d134        3 weeks ago         200MB
registry                      latest              2e2f252f3c88        7 weeks ago         33.3MB

将标记的镜像推送到私有仓库:

[root@localhost ~]# docker push 192.168.137.20:5000/centos6
The push refers to repository [192.168.137.20:5000/centos6]
Get https://192.168.137.20:5000/v2/: dial tcp 192.168.137.20:5000: connect: connection refused

解决以上错误信息:

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

改为

{ "insecure-registries":["192.168.137.20:5000"] }                    //注意不能在后面加,否则还是会出错
[root@localhost ~]# systemctl restart docker
[root@localhost ~]# docker ps -a
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                         PORTS               NAMES
f81917ea6f5d        registry            "/entrypoint.sh /etc…"   2 hours ago         Exited (2) About an hour ago                       cocky_banach
fe6e1cdb1f20        centos6             "bash"                   16 hours ago        Exited (137) 4 hours ago                           centos6_1
d80e3c0fabc5        centos6             "bash"                   17 hours ago        Exited (137) 4 hours ago                           agitated_shtern
6a30c38e5dcd        centos6             "bash"                   22 hours ago        Exited (137) 4 hours ago                           reverent_bartik

这里开始我重新搭建docker,所以CONTAINER ID和之前的不一样(docker开始下载的是centos7的镜像)

[root@localhost ~]# docker start f81917ea6f5d
f81917ea6f5d
[root@localhost ~]# docker push 192.168.137.20:5000/centos7
The push refers to repository [192.168.137.20:5000/centos7]
788edba9eaa8: Pushed
latest: digest: sha256:1501c3e328319a0d3207202b2495474d05e756ee158a9e80e764b5083fc2f9a2 size: 529
[root@localhost ~]# curl 127.0.0.1:5000/v2/_catalog
{"repositories":["centos7"]}
[root@localhost ~]# docker tag ubuntu 192.168.137.20:5000/ubuntu
[root@localhost ~]# docker push 192.168.137.20:5000/ubuntu
The push refers to repository [192.168.137.20:5000/ubuntu]
76c033092e10: Pushed
2146d867acf3: Pushed
ae1f631f14b7: Pushed
102645f1cf72: Pushed
latest: digest: sha256:6b9eb699512656fc6ef936ddeb45ab25edcd17ab94901790989f89dbf782344a size: 1150
[root@localhost ~]# curl 127.0.0.1:5000/v2/_catalog
{"repositories":["centos7","ubuntu"]}

下载私有库镜像:

[root@localhost ~]# docker pull 192.168.137.20:5000/ubuntu
Using default tag: latest
latest: Pulling from ubuntu
Digest: sha256:6b9eb699512656fc6ef936ddeb45ab25edcd17ab94901790989f89dbf782344a
Status: Image is up to date for 192.168.137.20:5000/ubuntu:latest

在21机器上拉取镜像:

[root@zhangfei-02 ~]# docker pull 192.168.137.20:5000/ubuntu
Using default tag: latest
Error response from daemon: Get https://192.168.137.20:5000/v2/: http: server gave HTTP response to HTTPS client
[root@zhangfei-02 ~]# vim /etc/docker/daemon.json
{
"insecure-registries":["192.168.137.20:5000"]                            //私有仓库地址
}
[root@zhangfei-02 ~]# systemctl restart docker
[root@zhangfei-02 ~]# docker pull 192.168.137.20:5000/ubuntu
Using default tag: latest
latest: Pulling from ubuntu
473ede7ed136: Pull complete
c46b5fa4d940: Pull complete
93ae3df89c92: Pull complete
6b1eed27cade: Pull complete
Digest: sha256:6b9eb699512656fc6ef936ddeb45ab25edcd17ab94901790989f89dbf782344a
Status: Downloaded newer image for 192.168.137.20:5000/ubuntu:latest
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值