【问题标题】:Docker Swarm : docker stack deploy results on untagged images <none>Docker Swarm:docker stack 在未标记的图像上部署结果 <none>
【发布时间】:2018-10-13 15:19:23
【问题描述】:

我正在使用 docker swarm mode host 将一些图像从我的注册表部署到我的应用程序服务器中:

我在注册表中的图像是这样的(执行docker images):

REPOSITORY                                                 TAG                   IMAGE ID            CREATED            SIZE
localhost:5000/myApp                                       G02R00C09_myTag   c1fc2242f9a0        2 hours ago         272MB

my docker compose file 下,我的服务如下所示:

---
version: '3.4'
services:
  ihm:
    image: myRegistryServer:5000/myApp:G02R00C09_myTag   
    stdin_open: true
    volumes:
    - /opt/logs:/opt/logs
    tty: true
    ports:
      - target: 80
        published: 80
        protocol: tcp
        mode: host
    deploy:
      mode: global
      placement:
        constraints:
          - node.labels.type == abc
    healthcheck:
      disable: true

-> 执行docker stack deploy 后:

我的堆栈和服务运行良好(当我运行 docker stack lsdocker service ls 时,一切正常)

-> 但是在运行 docker images 时,我确实得到了我的图像 但带有 &lt;none&gt; 标签

image:  myRegistryServer:5000/myApp      <none> 

【问题讨论】:

  • 你是如何构建图像的(用于构建它的命令)?也可以试试curl myRegistryServer:5000/v2/myApp/tags/list -v 看看注册表是否显示你想要的标签。
  • 我已经使用 ansible 的 docker_image 模块构建了它,它可以在注册表中成功标记图像
  • curl 显示什么?应该是这样的。
  • > GET /ihm/tags/list HTTP/1.1 > 用户代理:curl/7.29.0 > 主机:myResgitryServer:5000 > 接受:/ >
  • 为什么您的注册表无法访问?

标签: docker docker-compose dockerfile docker-swarm docker-registry


【解决方案1】:

这是正常的。使用 Swarm Stacks 时,它会将您的标签转换为该图像的 SHA256 并下载该特定 ID。这保证了每个节点都有相同的图像。如果它只依赖于标签,您可能会在docker push 中重复使用标签,并且不同的节点可能会下载不同的图像。

您可以看到docker service lsdocker stack ps &lt;stackname&gt; 中使用的标签

【讨论】:

  • 服务被移除后如何进行清理?
  • 我假设您在谈论图像或体积?这些是服务创建但不会删除的唯一对象。查看prune 命令,例如docker image prune --help,以及我使用日常任务自动修剪所有节点上所有未使用图像的示例:github.com/BretFisher/dogvscat/blob/master/stack-prune.yml
猜你喜欢
  • 2022-11-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多