docker 镜像中心搭建

1.由于国外镜像很慢,所以用了网易蜂巢的镜像
docker pull hub.c.163.com/library/registry:2.5.2
本地的存储空间挂载到容器内部,持久保存镜像中心文件
docker run -d -p 5000:5000 -v /opt/data/registry:/tmp/registry hub.c.163.com/library/registry:2.5.2
以上步骤将docker镜像中心启动完成
2.客户机push镜像的时候可能会出现 http: server gave HTTP response to HTTPS client
网上一些解决办法:

在”/etc/docker/“目录下,创建”daemon.json“文件。在文件中写入:

{ "insecure-registries":["192.168.1.100:5000"] }
写入后sudo restart docker 重启失败,提示restart: Job failed to restart
查看docker日志/var/log/upstart/docker.log,发现错误
unable to configure the Docker daemon with file /etc/docker/daemon.json: the following directives are specified both as a flag and in the configuration file: insecure-registries: (from flag: [xx.xxx.xx.xxx:5000], from file: [192.168.1.100:5000])
查询资料以后解决办法为:
vi /etc/default/docker添加DOCKER_OPTS="-H 0.0.0.0:2375 -H unix:///var/run/docker.sock --insecure-registry=192.168.1.100:5000"
保存,重启成功。


原文地址:https://www.cnblogs.com/dayangcong/p/7889466.html