我在CentOS上运行了一个docker 1.12。我试图添加不安全的注册表,文档中提到的东西不起作用。系统使用systemd
,因此我创建了一个/etc/systemd/system/docker.service.d/50-insecure-registry.conf
文件。
$ cat /etc/systemd/system/docker.service.d/50-insecure-registry.conf
[Service]
Environment='DOCKER_OPTS=--insecure-registry="hostname.cloudapp.net:5000"'
加载守护进程并重新启动docker service后,systemd显示环境变量在那里
$ sudo systemctl show docker | grep Env
Environment=DOCKER_OPTS=--insecure-registry="hostname.cloudapp.net:5000"
但是当我运行docker info
时,我不会看到添加了不安全的注册表
$ 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
有什么可以做的吗?我错过了什么吗?
更新
通过添加包含以下内容的文件/etc/docker/daemon.json
解决了该问题
{
"insecure-registries" : [ "hostname.cloudapp.net:5000" ]
}
然后重启docker
sudo systemctl daemon-reload
sudo systemctl restart docker
在不安全的注册表hostname.cloudapp.net:500
之后。
答案 0 :(得分:98)
(从问题中复制答案)
要添加不安全的泊坞窗注册表,请添加包含以下内容的文件/etc/docker/daemon.json
:
{
"insecure-registries" : [ "hostname.cloudapp.net:5000" ]
}
然后重启docker。
答案 1 :(得分:8)
创建/etc/docker/daemon.json文件并添加以下内容然后在CentOS 7上重启docker解决了这个问题。
{
"insecure-registries" : [ "hostname.cloudapp.net:5000" ]
}
答案 2 :(得分:3)
使用/etc/docker/daemon.json
文件的解决方案在Ubuntu上对我不起作用。
通过在/etc/default/docker
文件中为Docker守护程序提供命令行选项,例如,我可以在Ubuntu上配置Docker不安全注册表:
# /etc/default/docker
DOCKER_OPTS="--insecure-registry=a.example.com --insecure-registry=b.example.com"
可以使用相同的方法为docker映像和卷存储,默认DNS服务器等配置自定义目录。
现在,在Docker守护进程重新启动后(执行sudo service docker restart
之后),运行docker info
将显示:
Insecure Registries:
a.example.com
b.example.com
127.0.0.0/8
答案 3 :(得分:0)
对我来说,解决方案是将注册表添加到此处:
/ etc / sysconfig / docker-registries
DOCKER_REGISTRIES=''
DOCKER_EXTRA_REGISTRIES='--insecure-registry b.example.com'
答案 4 :(得分:0)
如果您已经有一个config.json文件,那么最终文件应该看起来像这样...
registry.myprivate.com
就是给我带来麻烦的那个。
{
"auths": {
"https://index.docker.io/v1/": {
"auth": "xxxxxxxxxxxxxxxxxxxx=="
},
"registry.myprivate.com": {
"auth": "xxxxxxxxxxxxxxxxxxxx="
}
},
"HttpHeaders": {
"User-Agent": "Docker-Client/19.03.8 (linux)"
},
"insecure-registries" : ["registry.myprivate.com"]
}
答案 5 :(得分:0)
任何想要在 amazon linux 2 上添加不安全注册表的人: 您必须更改 /etc/sysconfig/docker 下的设置,然后重新启动 docker 守护进程:这是我的 /etc/sysconfig/docker 的样子
# The max number of open files for the daemon itself, and all
# running containers. The default value of 1048576 mirrors the value
# used by the systemd service unit.
DAEMON_MAXFILES=1048576
# Additional startup options for the Docker daemon, for example:
# OPTIONS="--ip-forward=true --iptables=true"
# By default we limit the number of open files per container
OPTIONS="--default-ulimit nofile=1024:4096 --insecure-registry yourinsecureregistryhostname:port"
# How many seconds the sysvinit script waits for the pidfile to appear
# when starting the daemon.
DAEMON_PIDFILE_TIMEOUT=10
答案 6 :(得分:0)
对于我在 Ubuntu 20.04 中更好的方法是编辑 systemd 服务
/lib/systemd/system/docker.service
并在 [Service] 后面添加此行
Environment=DOCKER_OPTS=--insecure-registry=10.0.0.10:6000
或者可以使用sed通过2个命令自动完成,它会在[Service]后面添加一行
sed 's/\[Service\]/\[Service\] \nEnvironment=DOCKER_OPTS=--insecure-registry=10.0.0.10:6000/' /lib/systemd/system/docker.service > /lib/systemd/system/docker.service.tmp
mv /lib/systemd/system/docker.service.tmp /lib/systemd/system/docker.service
答案 7 :(得分:0)
在 Mac 上。 source
~/Library/Containers/com.docker.docker/Data/database
git reset --hard
com.docker.driver.amd64-linux
个文件夹~/Library/Containers/com.docker.docker/Data/database/com.docker.driver.amd64-linux/etc/docker
daemon.json
文件答案 8 :(得分:-1)
在Amazon Linux上设置本地内部JFrog Docker私有注册表后,我碰巧遇到了类似的问题。
我为解决该问题所做的以下努力:
通过修改/ etc / sysconfig / docker文件中的OPTIONS变量,添加了“ --insecure-registry xx.xx.xx.xx:8081”:
OPTIONS="--default-ulimit nofile=1024:40961 --insecure-registry hostname:8081"
然后重新启动Docker。
然后,我能够使用以下命令登录到本地Docker注册表:
docker login -u admin -p password hostname:8081
答案 9 :(得分:-3)
在要拉取 docker 镜像的位置创建 /etc/docker/daemon.json
文件并将以下内容添加到该文件中
{
"insecure-registries" : [ "hostname.cloudapp.net:5000" ]
}
有关创建私有 Docker 注册表的深入说明,请参阅我的博客文章:https://geekdosage.com/how-to-create-a-private-docker-registry-in-ubuntu-20-04/