标签:ubuntu16.04 docker 私有仓库 registry
1、配置docker的国内加速器docker版本为1.13.1需要配置一下daemon.json
配置阿里云的docker加速器:
wangpeng@ubuntu:~$ sudo vim /etc/docker/daemon.json { "registry-mirrors": [ "https://kv3qfp85.mirror.aliyuncs.com" ] }
2、拉取registry仓库docker镜像
wangpeng@ubuntu:~$ sudo docker pull registry
3、创建registry docker进程
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
4、测试上传一个镜像
下载一个测试镜像
wangpeng@ubuntu:~$ sudo docker pull busybox
将busybox镜像重命名为本地镜像格式与本地registry相匹配。
镜像名称由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
5、使用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
上传报错的问题就此解决
6、下载镜像测试一下
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
ubuntu16.04搭建docker_1.13.1私有仓库
标签:ubuntu16.04 docker 私有仓库 registry
原文地址:http://blog.51cto.com/wangpengtai/2093613