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/