環境 node
vmware虛擬機 linux
Ip:192.168.190.139 nginx
Ip:192.168.190.140 docker
Ip:192.168.0.122 registry json
Docker 1.12.2 api
Docker 版本1.12.2 其它版本配置不一樣 curl
[demo@node139 ~]$ docker version ide
Client: ui
Version: 1.12.2 url
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