一、配置docker的國內加速器
docker
docker版本爲1.13.1須要配置一下daemon.jsonjson
配置阿里雲的docker加速器:ubuntu
wangpeng@ubuntu:~$ sudo vim /etc/docker/daemon.json { "registry-mirrors": [ "https://kv3qfp85.mirror.aliyuncs.com" ] }
二、拉取registry倉庫docker鏡像vim
wangpeng@ubuntu:~$ sudo docker pull registry
三、建立registry docker進程
bash
wangpeng@ubuntu:~$ sudo docker run -d --name registry --restart=always -v /myregistry:/var/lib/registry registry wangpeng@ubuntu:~$ sudo docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES d8f77abe36a7 registry "/entrypoint.sh /e..." 2 hours ago Up 2 hours 0.0.0.0:5000->5000/tcp registry
四、測試上傳一個鏡像
curl
下載一個測試鏡像tcp
wangpeng@ubuntu:~$ sudo docker pull busybox
將busybox鏡像重命名爲本地鏡像格式與本地registry相匹配。
ide
鏡像名稱由registry和tag兩部分組成,registry完整格式:[registry_ip]:[registry:port]/[user]/[image_name:version]測試
wangpeng@ubuntu:~$ sudo docker tag busybox 192.168.56.101:5000/wangpeng/test:v1.0
五、使用docker push命令上傳鏡像
阿里雲
wangpeng@ubuntu:~$ sudo docker push 192.168.56.101:5000/wangpeng/test:v1.0
查看鏡像
wangpeng@ubuntu:~$ curl http://192.168.56.101:5000/v2/_catalog {"repositories":["wangpeng/my-image","wangpeng/test"]}
在此須要配置daemon.json的insecure-registries,爲了解決https的報錯,由於docker默認使用https協議,可是本地如今只支持http協議
不配置daemon.json的話會出現一下錯誤:
Get https://192.168.56.101:5000/v1/_ping: http: server gave HTTP response to HTTPS clie
配置以下:
wangpeng@ubuntu:~$ sudo vim /etc/docker/daemon.json { "registry-mirrors": [ "https://kv3qfp85.mirror.aliyuncs.com" ], "insecure-registries": [ "192.168.56.101:5000" ] }
重啓docker進程
wangpeng@ubuntu:~$ sudo systemctl restart docker
上傳報錯的問題就此解決
六、下載鏡像測試一下
wangpeng@ubuntu:~$ sudo docker pull 192.168.56.101:5000/wangpeng/test:v1.0 v1.0: Pulling from wangpeng/test Digest: sha256:73a74253ed45caebc619d95b1d84e4d67a64e5b6d81e31ac7c496b9c11128d74 Status: Image is up to date for 192.168.56.101:5000/wangpeng/test:v1.0