docker堆栈部署结果为“无此类映像错误”。 [英] docker stack deploy results in "No such image error"

查看:233
本文介绍了docker堆栈部署结果为“无此类映像错误”。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用docker swarm,并想使用 docker-compose 部署服务。我的服务使用了名为 myuser / myrepo:mytag 的自定义映像,该映像已成功部署到Docker-Hub到私有存储库中。

I am using docker swarm and would like to deploy a service with docker-compose. My service uses a custom image called myuser/myrepo:mytag that I successfully deploy to Docker-Hub to a private repository.

我的docker-compose看起来像这样:

My docker-compose looks like this:

version: "3.3"

services:

  myservice:
    image: myuser/myrepo:mytag
    ports:
      - "8080:8080"

在执行之前,我使用以下命令成功提取了图像: docker pull myuser / myrepo:mytag

Before executing, I successfully pulled the image with: docker pull myuser/myrepo:mytag

当我运行 docker stack deploy -c docker-compose.yml myapp 时,我总是收到错误: 没有这样的图像:myuser / myrepo:mytag

When I run docker stack deploy -c docker-compose.yml myapp I always receive the error: "No such image: myuser/myrepo:mytag".

有趣的是,仅使用以下文件运行同一文件: docker -组成(即不使用群集模式),一切正常,服务启动。

Interestingly, running the same file using only: docker-compose up (i.e. without swarm mode) everything works fine and the service starts up.

我真的不明白为什么这会失败?
我已经尝试使用 docker系统修剪清理docker,然后重新镜像,但没有成功。

I really don't understand why this is failing? I've already tried cleaning up docker with docker system prune and then repull my image, no success.

推荐答案

已找到解决方案。
我的图像托管在一个专用存储库中。
除了群集管理器(我在其中执行命令)之外,我还有一个正在运行的群集工作器。

Already found the solution. My image is hosted on a private repository. Besides the swarm manager (where I executed the commands), I had a running swarm worker.

当我运行 docker stack deploy时-c docker-compose.yml myapp docker将服务部署到工作节点(不是我想的管理节点)。
在工作程序节点上,docker没有凭据可从私有存储库中提取映像。
因此,要解决此问题,请通过标志-with-registry-auth (将存储库的凭据推送到工作程序节点)或确保该服务将部署到存在映像的节点。

When I ran docker stack deploy -c docker-compose.yml myapp docker deployed the service to the worker node (not the manager node as I thought). At the worker node, docker had no credentials to pull the image from the private repository. Hence, to fix this either pass the flag --with-registry-auth (which pushes the credentials for the repository to the worker node) or make sure that the service is deployed to a node where the image is present.

请参阅: https://docs.docker.com/engine/reference/commandline/deploy/

这篇关于docker堆栈部署结果为“无此类映像错误”。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆