部署私有Docker Registry和使用
环境
vmware虚拟机
Ip:192.168.190.139
Ip:192.168.190.140
Ip:192.168.0.122 registry
Docker 1.12.2
Docker 版本1.12.2 其它版本配置不同
[demo@node139 ~]$ docker version
Client:
Version: 1.12.2
API version: 1.24
Go version: go1.6.3
Git commit: bb80604
Built:
OS/Arch: linux/amd64
Server:
Version: 1.12.2
API version: 1.24
Go version: go1.6.3
Git commit: bb80604
Built:
OS/Arch: linux/amd64
创建文件
每台客户端机器都需要添加这个文件
[demo@node140 ~]$ sudo vi /etc/docker/daemon.json
添加内容如下:
{ "insecure-registries":["192.168.0.122:5000"] }
[demo@node139 ~]$ sudo systemctl daemon-reload
[demo@node139 ~]$ sudo systemctl restart docker.service
启动registry容器
在192.168.0.122机器上启动registry
docker run -d -p 5000:5000 -v /opt/data/registry:/tmp/registry registry
接下来修改一个该镜像的tag。
如果加上版本号的话,下载的时候也要加上版本号,默认为latest
如docker tag gliderlabs/consul-server 192.168.0.122:5000/gliderlabs/consul-server:1.0 这样需要一个镜像打打两个标签,一个有版本号一个没有版本号,下载的时候不加版本号就是下载latest的镜像内容
如果下载的镜像有版本号那打标签时也要把版本号加上才可以格式 imagename:version(tag name)
[demo@node139 ~]$ docker tag gliderlabs/consul-server 192.168.0.122:5000/gliderlabs/consul-server
[demo@node139 ~]$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
logapi1_0 latest c5fa33c25d6d 2 days ago 269.4 MB
registry latest c9bd19d022f6 7 days ago 33.27 MB
192.168.0.122:5000/gliderlabs/consul-server latest a41d4b20564f 2 weeks ago 29.13 MB
gliderlabs/consul-server latest a41d4b20564f 2 weeks ago 29.13 MB
busybox latest e02e811dd08f 2 weeks ago 1.093 MB
docker/ucp latest 08cd64894407 3 weeks ago 20.03 MB
microsoft/dotnet 1.0.0-core 2e2f5fffbe3c 6 weeks ago 253.2 MB
上传镜像
[demo@node139 ~]$ docker push 192.168.0.122:5000/gliderlabs/consul-server
The push refers to a repository [192.168.0.122:5000/gliderlabs/consul-server]
bc328607dcbb: Pushed
d44f2294d635: Pushed
d68e97c6f9dd: Pushed
9007f5987db3: Pushed
latest: digest: sha256:4d6c0a54914fb1a9419ec5b5f64381f5d3456103f12893edccc987353572b8f6 size: 1153
查看所有镜像
[demo@node139 ~]$ curl http://192.168.0.122:5000/v2/_catalog
{"repositories":["gliderlabs/consul-server"]}
查看指定镜像tag详情
[demo@node139 ~]$ curl http://192.168.0.122:5000/v2/gliderlabs/consul-server/tags/list
{"name":"gliderlabs/consul-server","tags":["latest"]}
下载镜像
格式:ip地址/镜像名称
[demo@node140 ~]$ docker pull 192.168.0.122:5000/gliderlabs/consul-server
Using default tag: latest
latest: Pulling from gliderlabs/consul-server
c0cb142e4345: Already exists
89e3bde74942: Pull complete
9a34f5ce39c4: Pull complete
fbfe7802927b: Pull complete
Digest: sha256:4d6c0a54914fb1a9419ec5b5f64381f5d3456103f12893edccc987353572b8f6
Status: Downloaded newer image for 192.168.0.122:5000/gliderlabs/consul-server:latest
[demo@node140 ~]$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
logapi1_0 latest db03033fc5a0 2 days ago 269.4 MB
nginx latest e43d811ce2f4 4 days ago 181.4 MB
192.168.190.140:5000/nginx latest e43d811ce2f4 4 days ago 181.4 MB
registry latest c9bd19d022f6 7 days ago 33.27 MB
vfarcic/docker-flow-proxy latest df8472f50971 12 days ago 42.58 MB
192.168.0.122:5000/gliderlabs/consul-server latest a41d4b20564f 2 weeks ago 29.13 MB
busybox latest e02e811dd08f 2 weeks ago 1.093 MB
microsoft/dotnet 1.0.0-core 2e2f5fffbe3c 6 weeks ago 253.2 MB