Docker私有仓库3

https://www.cnblogs.com/zeppelin/p/5906435.html(上篇地址)

三、测试上两篇

 #测试一下

[root@lh-2 data]# pwd
/opt/data
[root@lh-2 data]# rm -rf registry/

[root@lh-2 data]# docker images
127.0.0.1:5000/nginx                 latest              4efb2fcdb1ab        2 weeks ago         183.4 MB
[root@lh-2 data]# docker push 127.0.0.1:5000/nginx
The push refers to a repository [127.0.0.1:5000/nginx]
69ecf026ff94: Retrying in 7 seconds 
d7953e5e5bba: Retrying in 7 seconds 
2f71b45e4e25: Retrying in 7 seconds 
^C71b45e4e25: Preparing

我把本地映射目录删了,push出错。

 

#重新运行一个容器

[root@lh-2 data]# docker ps 
CONTAINER ID        IMAGE                           COMMAND                  CREATED             STATUS              PORTS                                          NAMES
23397ef79ec5        docker.io/registry              "/entrypoint.sh /etc/"   23 minutes ago      Up 23 minutes       0.0.0.0:5000->5000/tcp                         berserk_hypatia
[root@lh-2 data]# docker stop 23397ef79ec5
23397ef79ec5
[root@lh-2 data]# docker rm 23397ef79ec5
23397ef79ec5
[root@lh-2 data]# docker run -d -p 5000:5000 -v /opt/data/registry:/var/lib/registry --privileged=true docker.io/registry
e5810127dcc79d57d307ff5e49c6e9390019ada5ffb44a29d55b390eec758475
[root@lh-2 data]# docker push 127.0.0.1:5000/nginx
The push refers to a repository [127.0.0.1:5000/nginx]
69ecf026ff94: Pushed 
d7953e5e5bba: Pushed 
2f71b45e4e25: Pushed 
latest: digest: sha256:d33834dd25d330da75dccd8add3ae2c9d7bb97f502b421b02cecb6cb7b34a1b6 size: 926

 

#查看映射目录,已自动创建

[root@lh-2 data]# pwd
/opt/data
[root@lh-2 data]# ls
Registry

 

[root@lh-2 data]# tree
.
└── registry
    └── docker
        └── registry
            └── v2
                ├── blobs
                │   └── sha256
                │       ├── 0b
                │       │   └── 0bed9719ddcb355fb9220423d3dd9cd6c41d8e0be5f44580e3929da574db4530
                │       │       └── data
                │       ├── 0f
                │       │   └── 0fc04568277e2ac7eeab8071421127677b1d912bec0ff7319cbfab5925c65179
                │       │       └── data
                │       ├── 35
                │       │   └── 357ea8c3d80bc25792e010facfc98aee5972ebc47e290eb0d5aea3671a901cab
                │       │       └── data
                │       ├── 4e
                │       │   └── 4efb2fcdb1ab05fb03c9435234343c1cc65289eeb016be86193e88d3a5d84f6b
                │       │       └── data
                │       └── d3
                │           └── d33834dd25d330da75dccd8add3ae2c9d7bb97f502b421b02cecb6cb7b34a1b6
                │               └── data
                └── repositories
                    └── nginx
                        ├── _layers
                        │   └── sha256
                        │       ├── 0bed9719ddcb355fb9220423d3dd9cd6c41d8e0be5f44580e3929da574db4530
                        │       │   └── link
                        │       ├── 0fc04568277e2ac7eeab8071421127677b1d912bec0ff7319cbfab5925c65179
                        │       │   └── link
                        │       ├── 357ea8c3d80bc25792e010facfc98aee5972ebc47e290eb0d5aea3671a901cab
                        │       │   └── link
                        │       └── 4efb2fcdb1ab05fb03c9435234343c1cc65289eeb016be86193e88d3a5d84f6b
                        │           └── link
                        ├── _manifests
                        │   ├── revisions
                        │   │   └── sha256
                        │   │       └── d33834dd25d330da75dccd8add3ae2c9d7bb97f502b421b02cecb6cb7b34a1b6
                        │   │           └── link
                        │   └── tags
                        │       └── latest
                        │           ├── current
                        │           │   └── link
                        │           └── index
                        │               └── sha256
                        │                   └── d33834dd25d330da75dccd8add3ae2c9d7bb97f502b421b02cecb6cb7b34a1b6
                        │                       └── link
                        └── _uploads

35 directories, 12 files

 

#进入容器内部

[root@lh-2 data]# docker exec -it b445269f7e43 /bin/sh
/var/lib/registry/docker/registry/v2/repositories # ls
Nginx

 

#把ubuntu镜像推向仓库

[root@lh-2 data]# docker push 192.168.0.34:5000/ubuntu 
The push refers to a repository [192.168.0.34:5000/ubuntu]
5f70bf18a086: Pushed 
0d81735d8272: Pushed 
982549bd6b32: Pushed 
8698b31c92d5: Pushed 
latest: digest: sha256:a47804d268c600572aab1f564e38d1ef009bd7c7ce4bbd325be51973541e5431 size: 1129

 

#查看镜像

[root@lh-2 data]# curl -XGET 192.168.0.34:5000/v2/_catalog
{"repositories":["nginx","ubuntu"]}
[root@lh-2 data]# curl -XGET 192.168.0.34:5000/v2/nginx/tags/list
{"name":"nginx","tags":["latest"]}
[root@lh-2 data]# curl -XGET 192.168.0.34:5000/v2/ubuntu/tags/list
{"name":"ubuntu","tags":["latest"]}

 

#从其他机器拉私有仓库镜像

[root@lh-1 ~]# docker images
REPOSITORY                  TAG                 IMAGE ID            CREATED             SIZE
192.168.0.34:5000/busybox   latest              2b8fd9751c4c        11 weeks ago        1.093 MB
[root@lh-1 ~]# docker pull 192.168.0.34:5000/ubuntu
Using default tag: latest
Trying to pull repository 192.168.0.34:5000/ubuntu ... 
latest: Pulling from 192.168.0.34:5000/ubuntu
8387d9ff0016: Pull complete 
3b52deaaf0ed: Pull complete 
4bd501fad6de: Pull complete 
a3ed95caeb02: Pull complete 
Digest: sha256:a47804d268c600572aab1f564e38d1ef009bd7c7ce4bbd325be51973541e5431
Status: Downloaded newer image for 192.168.0.34:5000/ubuntu:latest
[root@lh-1 ~]# docker images
REPOSITORY                  TAG                 IMAGE ID            CREATED             SIZE
192.168.0.34:5000/busybox   latest              2b8fd9751c4c        11 weeks ago        1.093 MB
192.168.0.34:5000/ubuntu    latest              3876b81b5a81        7 months ago        187.9 MB
[root@lh-1 ~]# 

 

#浏览器中查看

 

个人公众号:

 

posted @ 2016-09-25 17:55  派。  阅读(1203)  评论(0编辑  收藏  举报