Docker私有仓库

6
在一个虚拟服务器Ubuntu 14.04上,我安装了Docker,并试图将镜像推送到本地注册表中。我遵循了Docker博客上的指南,但是当我尝试推送镜像时,输出如下:

Error: Invalid registry endpoint https://xx.xx.xx.xx/v1/: Get https://xx.xx.xx.xx/v1/_ping: x509: certificate has expired or is not yet valid. If this private registry supports only HTTP or HTTPS with an unknown CA certificate, please add --insecure-registry xx.xx.xx.xx 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/xx.xx.xx.xx/ca.crt

我尝试在/etc/default/docker文件中添加--insecure-registry xx.xx.xx.xx并重新启动docker服务。但是,Docker启动失败,并显示消息:/proc/self/fd/9: 17: /etc/default/docker: --insecure-registry: not found
PS:我在一个Docker容器中运行我的注册表。

2
使用 --insecure-registry=xx.xx.xx.xx(不要忘记等号) - mbarthelemy
1
对于st0ne:是我的私有注册表repo.my.lan的fqdn。 @mbarthelemy不起作用,即使使用'='也不行。如果我使用docker -d --insecure-registry repo.coro.ced.it启动docker守护进程,它可以工作! - cresg820
我在新的一行输入了 --insecure-registry xx.xx.xx,而没有使用 DOCKER_OPTS="--insecure-registry xx.xx.xx.xx"。 - cresg820
您还可以将 CA 证书添加到受信任的证书中。 - joh.scheuer
这些解决方案中有没有解决你的问题? - Charlie
显示剩余3条评论
4个回答

8

我在使用Ubuntu 12.04和Docker 1.4.1时遇到了相同的问题。以下是我的解决方案:

$ sudo docker push "[host:ip:v6:addr:ess:is:here]:5000/myImage"
FATA[0002] Error: Invalid registry endpoint https://[host:ip:v6:addr:ess:is:here]:5000/v1/: Get https://[host:ip:v6:addr:ess:is:here]:5000/v1/_ping: EOF. If this private registry supports only HTTP or HTTPS with an unknown CA certificate, please add `--insecure-registry [host:ip:v6:addr:ess:is:here]: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/[host:ip:v6:addr:ess:is:here]:5000/ca.crt 

所以,我遇到了一个错误。

$ ps axwww | grep /usr/bin/docker
14655 ?        Ssl    2:06 /usr/bin/docker -d
14869 pts/0    S+     0:00 grep /usr/bin/docker

请注意,/usr/bin/docker 没有额外的参数。
$ echo 'DOCKER_OPTS="--insecure-registry [host:ip:v6:addr:ess:is:here]:5000"' | sudo tee -a /etc/default/docker
DOCKER_OPTS="--insecure-registry [host:ip:v6:addr:ess:is:here]:5000"
$ sudo service docker restart
docker stop/waiting
docker start/running, process 15615

让我们检查参数是否出现:

$ ps axwww | grep /usr/bin/docker
15615 ?        Ssl    0:00 /usr/bin/docker -d --insecure-registry [host:ip:v6:addr:ess:is:here]:5000
15663 pts/0    S+     0:00 grep /usr/bin/docker

是的,他们确实会。再试一次:
$ sudo docker push "[host:ip:v6:addr:ess:is:here]:5000/myImage"
The push refers to a repository [[host:ip:v6:addr:ess:is:here]:5000/myImage] (len: 1)
Sending image list
Pushing repository [host:ip:v6:addr:ess:is:here]:5000/myImage (1 tags)
511136ea3c5a: Image successfully pushed 
27d47432a69b: Pushing [================================================>  ] 189.8 MB/197.2 MB 0

感谢您解释如何使用ps命令验证DOCKER_OPTS是否生效。 - josephpconley

2

仅仅运行这个命令 docker run -p 5000:5000 -d registry 将会在https方面给你带来麻烦。

我发现这篇教程很有用:如何在Ubuntu 14.04上设置私有Docker注册表

它基本上通过nginx设置反向代理来访问私有注册表。我有1个vagrant盒子用于注册表,另一个vagrant盒子从该注册表中拉取内容。这很有效 :)

希望这可以帮到你


0

在主机中

  1- install docker machin
      curl -L https://github.com/docker/machine/releases/download/v0.14.0/docker-machine-`uname -s`-`uname -m` >/tmp/docker-machine && \
      sudo install /tmp/docker-machine /usr/local/bin/docker-machine
  2- Remove any proxy entry in /etc/systemd/system/docker.....
  3- Edit the daemon.json file, whose default location is /etc/docker/daemon.json
      {
      "insecure-registries" : ["myregistrydomain.com:5000"]
      }
  4- Generate crt: 
      $mkdir -p certs
      $openssl req -newkey rsa:4096 -nodes -sha256 -keyout certs/domain.key -x509 -days 365 -out certs/domain.crt
      Be sure to use the same name myregistrydomain.com as a CN.
      Copy the domain.crt file to /etc/docker/certs.d/myregistrydomain.com:5000/ca.crt on every Docker host. You do not need to restart Docker.

  5- pull registry image from docker hub 
      docker run -p 5000:5000 --name myregistry registry

在客户端中

  1- Remove any proxy entry in /etc/systemd/system/docker.....
  2- Edit the daemon.json file, whose default location is /etc/docker/daemon.json
      {
      "insecure-registries" : ["myregistrydomain.com:5000"]
      }     

我不太确定您是否需要在主机和客户端上都添加“insecure-registries”。 - Shōgun8

0
在主机上直接设置Docker注册表相当令人沮丧。设置本地Docker存储库的最简单方法是使用docker-registry Docker镜像。只需执行以下命令:
docker run -p 5000:5000 -d registry

而 Docker 应该下载官方的 Docker Registry 镜像。 之后,您可以连接到容器并自定义设置。 来源: http://www.devops-insight.com/2014/12/using-private-docker-repository-registry.html


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接