Docker Swarm - 无法在更新时从私有注册表中提取,仅适用于初始部署



我在执行更新或部署(在现有堆栈上(时遇到群工作节点不更新映像的问题。堆栈在创建时将始终工作

此解决方案仅适用于创建。

要重现此问题,请执行以下操作

1(创建一个容器,类似于带有索引的HTTPD.html,将其存储在private-registry.example.com/path/image

2( 创建测试.yml

version: '3.4'
services:
test:
# Use the build in the current pipeline
image: private-registry.example.com/path/image
deploy:
replicas: 3

3( 部署堆栈

docker login private-registry.example.com
docker stack deploy --with-registry-auth --compose-file=test.yml test

4(更新容器,更改一些文本

5( 重新部署堆栈

docker login private-registry.example.com
docker stack deploy --with-registry-auth --compose-file=test.yml test

群管理器将拥有最新的映像,群节点不会。

docker service ps test_test
ID                  NAME                                  IMAGE                                    NODE                            DESIRED STATE       CURRENT STATE             ERROR                              PORTS
j9497jwolee4        test_test.1       private-registry.example.com/path/image   swarm-slave-01.example.com   Running             Running 5 seconds ago
zsqxx3m0mpk3         _ test_test.1   private-registry.example.com/path/image   swarm-slave-01.example.com   Shutdown            Shutdown 7 seconds ago
sjjggcqmjcvo        test_test.2       private-registry.example.com/path/image   swarm-master.example.com     Running             Running 10 seconds ago
uyey60wv2vsc         _ test_test.2   private-registry.example.com/path/image   swarm-slave-01.example.com   Shutdown            Rejected 20 seconds ago   "No such image: private-registry..."
ttzvf4j3whk3         _ test_test.2   private-registry.example.com/path/image   swarm-slave-01.example.com   Shutdown            Rejected 25 seconds ago   "No such image: private-registry..."
x77e3r46zl1j         _ test_test.2   private-registry.example.com/path/image   swarm-master.example.com     Shutdown            Rejected 31 seconds ago   "No such image: private-registry..."
5a7lywn6zycz         _ test_test.2   private-registry.example.com/path/image   swarm-master.example.com     Shutdown            Rejected 36 seconds ago   "No such image: private-registry..."
qp1acqgthl33        test_test.3       private-registry.example.com/path/image   swarm-slave-02.example.com   Running             Running 11 seconds ago
osyn19o6c30j         _ test_test.3   private-registry.example.com/path/image   swarm-master.example.com     Shutdown            Shutdown 12 seconds ago

解决方法这每次都会拉取最新的映像,而不会出现问题。

docker login private-registry.example.com
docker stack rm test
docker stack deploy --with-registry-auth --compose-file=test.yml test

系统

Server Version: 18.06.1-ce
Operating System: Ubuntu 18.04.1 LTS

尽量不要使用--resolve-image never检查 docker 镜像摘要。看起来很像作品。

docker stack deploy --prune --with-registry-auth --resolve-image never -c docker-compose.yml xxxx

最新更新