将不安全的注册表添加到Docker [英] Add Insecure Registry to Docker
问题描述
我有一个在CentOS上运行的docker 1.12。我正在尝试向其中添加不安全的注册表,并且文档中提到的内容无法正常工作。系统使用 systemd
,所以我创建了 /etc/systemd/system/docker.service.d/50-insecure-registry.conf
文件。
I have a docker 1.12 running on CentOS. I am trying to add insecure registry to it and things mentioned in documentation just don't work. The system uses systemd
so I created a /etc/systemd/system/docker.service.d/50-insecure-registry.conf
file.
$ cat /etc/systemd/system/docker.service.d/50-insecure-registry.conf
[Service]
Environment='DOCKER_OPTS=--insecure-registry="hostname.cloudapp.net:5000"'
在加载守护程序并重新启动docker服务后,systemd显示环境变量存在
After loading daemon and restarting docker service, systemd shows that the environment variable is there
$ sudo systemctl show docker | grep Env
Environment=DOCKER_OPTS=--insecure-registry="hostname.cloudapp.net:5000"
但是当我运行 docker info
时,我看不到添加了不安全的注册表
But when I run docker info
I don't see that insecure registry added
$ docker info
........
Registry: https://index.docker.io/v1/
WARNING: bridge-nf-call-iptables is disabled
WARNING: bridge-nf-call-ip6tables is disabled
Insecure Registries:
127.0.0.0/8
将图像推送到 hostaneme.cloudapp.net
失败,
Pushing application (hostname.cloudapp.net:5000/application:latest)...
The push refers to a repository [hostname.cloudapp.net:5000/mozart_application]
ERROR: Get https://hostname.cloudapp.net:5000/v1/_ping: http: server gave HTTP response to HTTPS client
有什么可以做的吗?我想念什么吗?
Is there something that could be done ? Am I missing something ?
更新
通过添加文件 /etc/docker/daemon.json
具有以下内容
Resolved the issue by adding a file /etc/docker/daemon.json
with following content
{
"insecure-registries" : [ "hostname.cloudapp.net:5000" ]
}
然后重新启动docker
And then restart docker
sudo systemctl daemon-reload
sudo systemctl restart docker
在该不安全的注册表 hostname.cloudapp.net:500
起作用之后。
After that insecure registry hostname.cloudapp.net:500
works.
推荐答案
(从问题中复制答案)
要添加不安全的Docker注册表,请添加文件 /etc/docker/daemon.json
具有以下内容:
To add an insecure docker registry, add the file /etc/docker/daemon.json
with the following content:
{
"insecure-registries" : [ "hostname.cloudapp.net:5000" ]
}
,然后重新启动docker。
and then restart docker.
这篇关于将不安全的注册表添加到Docker的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!