docker - 在 swarm 中运行时无法从私有注册表推/拉
问题描述
当我在 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 注册表添加到不安全的注册表中。我究竟做错了什么?
解决方案
您已设置--replicas 2
服务,并且它们/some/path
从主机安装。这意味着:
- 同一主机上的2 个
docker-registry
容器访问/some/path
- 2个
docker-registry
不同主机上的容器访问/some/path
在这两种情况下,如何docker-registry
管理本地存储都与这种配置不兼容。Swarm 将在实例之间分发所有 API 请求,从而导致数据损坏和意外行为。
必须确保始终docker-registry
在同一主机上运行。/some/path
对于高可用性配置,文档中有提及。
推荐阅读
- delphi - 如何找到调用公共程序的表单
- javascript - loadJSON 未定义 - Chrome 扩展错误
- c++ - Rcpp调用的c++计数算法模板
- html - 图像在 HTML 中出现损坏
- java - Tomcat删除/work目录中的类后显示JSP
- java - 错误:Spring Boot,amazonRDS,org.springframework.beans.factory.BeanCreationException
- sms - 在发布到 slack 的每条短信上都出现错误 11200
- database - SQL1397N - DB2 服务登录失败
- android - 动态地将多个视图添加到 Recycler View
- sdk - 如何自定义 ArcGIS Pro OverviewMapControl 加载项?