列表的"docker堆栈部署"配置合并行为是什么



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项目中提出一个问题。

最新更新