docker - 列表的 `docker stack deploy`配置合并行为是什么?

标签 docker docker-swarm

Docker允许多个撰写文件

docker stack deploy -c base.yml -c env-specific.yml stack_name
给定一个base.yml为
version: "3.7"
services:
  portal:
    image: myimage
    networks:
    - traefik
    deploy:
      restart_policy:
        condition: any
        delay: 15s
      update_config:
        order: start-first
      labels:
        - "traefik.frontend.entryPoints=https,http"
        - "traefik.enable=true"
        - "traefik.docker.network=traefik"
        - "traefik.frontend.passHostHeader=true"
        - "traefik.frontend.insecureSkipVerify=true"
        - "traefik.port=8443"
        - "traefik.protocol=https"
和一个env-specific.yml作为
version: "3.7"
services:
  portal:
    deploy:
      replicas: 1
      resources:
        limits:
          cpus: '2'
          memory: 512M
        reservations:
          memory: 256M
      labels:
        - "traefik.frontend.rule=Host:my-server.com"
合并结果将是什么? (特别是labels)

最佳答案

我想说的是,大量堆栈的合并配置应与docker-compose config呈现的相同:

docker-compose -f base.yml -f env-specific.yml config
WARNING: Some services (portal) use the 'deploy' key, which will be ignored. Compose does not support 'deploy' configuration - use `docker stack deploy` to deploy to a swarm.
services:
  portal:
    deploy:
      labels:
        traefik.docker.network: traefik
        traefik.enable: "true"
        traefik.frontend.entryPoints: https,http
        traefik.frontend.insecureSkipVerify: "true"
        traefik.frontend.passHostHeader: "true"
        traefik.frontend.rule: Host:my-server.com
        traefik.port: '8443'
        traefik.protocol: https
      replicas: 1
      resources:
        limits:
          cpus: '2'
          memory: 512M
        reservations:
          memory: 256M
      restart_policy:
        condition: any
        delay: 15s
      update_config:
        order: start-first
    image: myimage
    networks:
      traefik: {}
version: '3.7'
部署堆栈并检查服务{stack_name} _portal:docker service inspect {stack_name}_portal --format '{{range $key, $value := .Spec.Labels}}{{$key}}: {{println $value}}{{end}}'。输出应列出合并的服务标签。
如果渲染的配置确实以不同方式处理合并,我建议在Docker的Github项目中提出一个问题。

关于docker - 列表的 `docker stack deploy`配置合并行为是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63178866/

相关文章:

docker - 在一个节点上部署一个 docker 堆栈(共同调度容器,如 docker swarm)

docker-swarm - 将所有 Docker Swarm 节点作为管理器运行的利弊?

node.js - Docker 中的 MongoDB 自动定期删除数据库

docker - 如何扩展图像,使其仍然有效?什么时候图像可以在 Dockerfile 的 from 行中?

docker - 如何在Docker集群上运行Redis集群?

amazon-web-services - 使用rexray/ebs运行TeamCity的Docker Swarm在AWS EBS中实现驱动器持久性的问题

Docker 注册表(本地): how to limit the number of unique tags per image?

bash - IBM/secure-gateway-client docker与--F(acl文件)选项一起运行

docker - 如何获取正在运行的 docker 容器的 IP 地址

c# - ASP.NET docker-compose 应用程序没有出现在分配的端口上