当我在swarm中运行docker注册表时:
docker service create \
--name docker-registry \
--mount type=bind,src=/some/path,dst=/var/lib/registry \
-e REGISTRY_HTTP_ADDR=0.0.0.0:5000 \
--publish 5000:5000 \
--replicas 2 \
registry:2
并尝试将其挂起(从另一台服务器)推送或拉到该注册表:
$ docker tag hello-world:latest 111.222.333.333:5000/hello-world
$ docker push 111.222.333.333:5000/hello-world
The push refers to a repository [111.222.333.333:5000/hello-world]
428c97da766c: Retrying in 1 second
但是当我将其作为容器运行时它可以工作:
docker run -d \
-p 5000:5000 \
--restart=always \
--name docker-registry \
-v /some/path:/var/lib/registry \
registry:2
我将IP注册表添加到不安全的注册表中。我在做什么错了?
答案 0 :(得分:1)
您已经设置了--replicas 2
的服务,并且它们从主机安装了/some/path
。这意味着:
docker-registry
容器访问/some/path
docker-registry
容器访问/some/path
在两种情况下,docker-registry
如何管理本地存储都与这种配置不兼容。 Swarm将在实例之间分配所有API请求,从而导致数据损坏和意外行为。
必须确保docker-registry
始终在同一主机上以相同的/some/path
运行。
对于高可用性配置,documentation中有提及。