Registry的部署
获取registry镜像
1
|
#docker pull registry:2.1.1
|
启动registry容器
1
2
3
4
5
6
7
8
9
|
#docker run -d -v /opt/registry:/var/lib/registry -p 5000:5000 --restart=always --name registry registry:2.1.1
查看进程
# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
ac291ed888fe registry:2.1.1
"/bin/registry /et..."
27 minutes ago Up 27 minutes 0.0.0.0:5000->5000
/tcp
registry
验证服务是否正常
#curl http://127.0.0.1:5000/v2/
{}
|
上传镜像
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
查看本地已有镜像
# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx v2 570d531c994a 4 hours ago 107MB
nginx latest b8efb18f159b 3 weeks ago 107MB
centos 6.8 0cd976dc0a98 11 months ago 195MB
registry 2.1.1 52bb991b482e 22 months ago 220MB
创建docker tag 镜像
# docker tag nginx:v2 127.0.0.1:5000/nginx:v2
即用ningx:v2创建 127.0.0.1:5000
/nginx
:v2的镜像
# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
127.0.0.1:5000
/nginx
v2 570d531c994a 4 hours ago 107MB
nginx v2 570d531c994a 4 hours ago 107MB
nginx latest b8efb18f159b 3 weeks ago 107MB
centos 6.8 0cd976dc0a98 11 months ago 195MB
registry 2.1.1 52bb991b482e 22 months ago 220MB
push镜像到本地仓库
# docker push 127.0.0.1:5000/nginx:v2
The push refers to a repository [127.0.0.1:5000
/nginx
]
04a8761254c7: Pushed
af5bd3938f60: Pushed
29f11c413898: Pushed
eb78099fbf7f: Pushed
v2: digest: sha256:9586184eb142f8c66decfd4fd7b3a2b54abfcb0f0a25541e69ba3725c61ba8b3 size: 8522
查看是否已经上传
# curl http://192.168.12.109:5000/v2/_catalog
{
"repositories"
:[
"nginx"
]}
|
下载镜像
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
先删除已经有的镜像
[root@DockServer opt]
# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
127.0.0.1:5000
/nginx
v2 570d531c994a 4 hours ago 107MB
nginx v2 570d531c994a 4 hours ago 107MB
nginx latest b8efb18f159b 3 weeks ago 107MB
centos 6.8 0cd976dc0a98 11 months ago 195MB
registry 2.1.1 52bb991b482e 22 months ago 220MB
[root@DockServer opt]
# docker rmi -f 570d531c994a
Untagged: 127.0.0.1:5000
/nginx
:v2
Untagged: 127.0.0.1:5000
/nginx
@sha256:9586184eb142f8c66decfd4fd7b3a2b54abfcb0f0a25541e69ba3725c61ba8b3
Untagged: nginx:v2
Deleted: sha256:570d531c994a495b7cba536ac12f9d640141cbbaecd9ae8a114816681a8ca750
Deleted: sha256:f4a3f9102faadf3e941a05724ffe69e3aa3dc1fee5de3762c374ee337a27d60b
[root@DockServer opt]
# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx latest b8efb18f159b 3 weeks ago 107MB
centos 6.8 0cd976dc0a98 11 months ago 195MB
registry 2.1.1 52bb991b482e 22 months ago 220MB
确定已经删除后,我们下载
[root@DockServer opt]
# docker pull 127.0.0.1:5000/nginx:v2
v2: Pulling from nginx
94ed0c431eb5: Already exists
9406c100a1c3: Already exists
aa74daafd50c: Already exists
79afb5d63c06: Pull complete
Digest: sha256:9586184eb142f8c66decfd4fd7b3a2b54abfcb0f0a25541e69ba3725c61ba8b3
Status: Downloaded newer image
for
127.0.0.1:5000
/nginx
:v2
[root@DockServer opt]
# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
127.0.0.1:5000
/nginx
v2 d296335af0a9 4 hours ago 107MB
nginx latest b8efb18f159b 3 weeks ago 107MB
centos 6.8 0cd976dc0a98 11 months ago 195MB
registry 2.1.1 52bb991b482e 22 months ago 220MB
|
可以看到已经本地仓库 可以成功上传 下载镜像了
本文转自 jackjiaxiong 51CTO博客,原文链接:http://blog.51cto.com/xiangcun168/1957392