Docker私有仓库3

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

三、测试上两篇

#测试一下

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

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

#重新运行一个容器

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

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

[root@lh- data]# pwd
/opt/data
[root@lh- data]# ls
Registry
[root@lh- data]# tree
.
└── registry
└── docker
└── registry
└── v2
├── blobs
│   └── sha256
│   ├── 0b
│   │   └── 0bed9719ddcb355fb9220423d3dd9cd6c41d8e0be5f44580e3929da574db4530
│   │   └── data
│   ├── 0f
│   │   └── 0fc04568277e2ac7eeab8071421127677b1d912bec0ff7319cbfab5925c65179
│   │   └── data
│   ├──
│   │   └── 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 directories, files

#进入容器内部

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

#把ubuntu镜像推向仓库

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

#查看镜像

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

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

[root@lh- ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
192.168.0.34:/busybox latest 2b8fd9751c4c weeks ago 1.093 MB
[root@lh- ~]# docker pull 192.168.0.34:/ubuntu
Using default tag: latest
Trying to pull repository 192.168.0.34:/ubuntu ...
latest: Pulling from 192.168.0.34:/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:/ubuntu:latest
[root@lh- ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
192.168.0.34:/busybox latest 2b8fd9751c4c weeks ago 1.093 MB
192.168.0.34:/ubuntu latest 3876b81b5a81 months ago 187.9 MB
[root@lh- ~]#

#浏览器中查看

Docker私有仓库3

Docker私有仓库3

Docker私有仓库3

个人公众号:

Docker私有仓库3

上一篇:zw版【转发·*nvp系列Delphi例程】HALCON SetComprise1


下一篇:Less(47)