docker工人 – 无法将图像推送到私人registry

我已经创build了我自己的私人registry,在我的服务器上通过拉和运行registry映像。

sudo docker run -d -p 5000:5000 registry 

之后,我尝试标记一个简单的图像,并将其推送到服务器。

 sudo docker tag ubuntu:latest localhost:5000/myprivateubuntu 

而我收到这个错误:

 Error: Invalid registry endpoint ... Get ... If this private registry supports only HTTP or HTTPS with an unknown CA certificate, please add '--insecure-registry localhost:5000' to the daemon's arguments. In the case of HTTPS, if you have access to the registry's CA certificate, no need for the flag; simply place the CA certificate at /etc/docker/certs.d/localhost:5000/ca.crt 

总之知道有什么问题?

停止服务。

 sudo service docker stop 

--insecure-registry参数重新启动服务:

 /usr/bin/docker -d --insecure-registry localhost:5000 

或编辑/etc/default/docker文件并添加以下行:

 DOCKER_OPTS="--insecure-registry localhost:5000" 

在docker中设置本地不安全的registry以及代理:

1)在Ubuntu中添加以下标志–insecure-registry IP:port在DOCKER_OPTS下的文件/ etc / default / docker

1.1)configurationno_proxy envvariables绕过本地IP /主机名/域名…因为代理可以抛出一个交互式味精…像继续和这个中间味精混淆docker客户端,最后超时…

1.2)如果configuration了域名,那么如果不使用DNS,不要忘记更新/ etc / hosts文件。

1.3)在/ etc / default / docker中设置了envvariableshttp_proxy和https_proxy …因为它允许从公司集线器外部下载图像。 格式http_proxy = http://用户名:密码@ proxy:端口

2)重新启动docker服务…如果作为服务安装,使用sudo服务docker重启

3)重新启动registry容器[sudodocker运行-p 5000:5000registry:2]

4)使用sudo docker标记imageid标记所需的图像IP:port / imagename / tagname ifany

5)推图像… sudodocker推ip:端口/ imagename

6)如果你想拉另一台机器的图像说B没有TLS / SSL,然后在B申请设置1,1.1和2. 如果这些更改不是在机器B …拉将失败。

从接受的答案的评论看来,解决scheme并不适用于所有人。 以下解决scheme适用于我。

为Docker创buildsystemd conf覆盖文件

 sudo mkdir /etc/systemd/system/docker.service.d sudo touch /etc/systemd/system/docker.service.d/docker.conf sudo vi /etc/systemd/system/docker.service.d/docker.conf 

添加以下这些行并保存

 [Service] ExecStart= ExecStart=/usr/bin/docker daemon -H fd:// $DOCKER_OPTS EnvironmentFile=-/etc/default/docker 

编辑/etc/default/docker

 sudo vi /etc/default/docker 

添加以下行并保存。 将localhost:5000replace为registry域名和端口

 DOCKER_OPTS="--insecure-registry localhost:5000" 

重新启动docker守护进程

重新加载configuration并重新启动docker ,如下所示

 sudo systemctl daemon-reload sudo systemctl restart docker