Docker私有仓库3

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Docker私有仓库3相关的知识,希望对你有一定的参考价值。

http://www.cnblogs.com/womars/p/5906435.html(上篇地址)

三、测试上两篇

 #测试一下

[[email protected]2 data]# pwd
/opt/data
[[email protected]-2 data]# rm -rf registry/

[[email protected]-2 data]# docker images
127.0.0.1:5000/nginx                 latest              4efb2fcdb1ab        2 weeks ago         183.4 MB
[[email protected]-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出错。

 

#重新运行一个容器

[[email protected]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
[[email protected]-2 data]# docker stop 23397ef79ec5
23397ef79ec5
[[email protected]-2 data]# docker rm 23397ef79ec5
23397ef79ec5
[[email protected]-2 data]# docker run -d -p 5000:5000 -v /opt/data/registry:/var/lib/registry --privileged=true docker.io/registry
e5810127dcc79d57d307ff5e49c6e9390019ada5ffb44a29d55b390eec758475
[[email protected]-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

 

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

[[email protected]2 data]# pwd
/opt/data
[[email protected]-2 data]# ls
Registry

 

[[email protected]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

 

#进入容器内部

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

 

#把ubuntu镜像推向仓库

[[email protected]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

 

#查看镜像

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

 

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

[[email protected]1 ~]# docker images
REPOSITORY                  TAG                 IMAGE ID            CREATED             SIZE
192.168.0.34:5000/busybox   latest              2b8fd9751c4c        11 weeks ago        1.093 MB
[[email protected]-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
[[email protected]-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
[[email protected]-1 ~]# 

 

#浏览器中查看

技术分享

技术分享

技术分享

 

以上是关于Docker私有仓库3的主要内容,如果未能解决你的问题,请参考以下文章

Docker容器私有仓库——Harbor私有仓库的搭建

Docker企业级私有仓库

docker-3.私有仓库

docker—搭建本地私有仓库

docker—搭建本地私有仓库

docker本地仓库和私有仓库