问题与此有关 command ,它必须是一个数组而不是多行字符串( > )。
command
>
另请注意,对于alpine版本(仅适用于alpine版本),您需要添加 traefik 之前 storeconfig :
traefik
storeconfig
proxy_init: image: traefik:1.6.3-alpine command: - "traefik" - "storeconfig" - ...
-
无效:
command: > traefik --consul --consul.watch --consul.endpoint=consul:8500 --consul.prefix=traefik
有效:
command: - "traefik" - "--consul" - "--consul.watch" - "--consul.endpoint=consul:8500" - "--consul.prefix=traefik"
visualizer: image: dockersamples/visualizer:latest volumes: - "/var/run/docker.sock:/var/run/docker.sock" networks: - traefik - default ports: - "8001:8080" deploy: labels: - "traefik.port=8080" - "traefik.tags=monitoring" - "traefik.docker.network=infra_traefik" - "traefik.backend=visualizer" - "traefik.frontend.rule=Host:visualizer.swarm.xxx.io" - "traefik.frontend.auth.basic=admin:$$apr1$$dxw2H03E$$VWrfVhKQWyaRiZ4XsfWCK/" restart_policy: condition: on-failure replicas: 1 placement: constraints: - node.labels.name == master consul: image: consul command: agent -server -bootstrap-expect=1 volumes: - consul-data:/consul/data environment: - CONSUL_LOCAL_CONFIG={"datacenter":"ams3","server":true} - CONSUL_BIND_INTERFACE=eth0 - CONSUL_CLIENT_INTERFACE=eth0 deploy: labels: - "traefik.enable=false" replicas: 1 placement: constraints: - node.role == manager restart_policy: condition: on-failure networks: - traefik proxy_init: image: traefik:1.6.3-alpine command: - "traefik" - "storeconfig" - "--api" - "--entrypoints=Name:http Address::80 Redirect.EntryPoint:https" - "--entrypoints=Name:https Address::443 TLS" - "--defaultentrypoints=http,https" - "--acme" - "--acme.storage=traefik/acme/account" - "--acme.entryPoint=https" - "--acme.httpChallenge.entryPoint=http" - "--acme.onHostRule=true" - "--acme.acmelogging=true" - "--acme.onDemand=false" - "--acme.email=xxx@gmail.com" - "--docker" - "--docker.swarmMode" - "--docker.domain=swarm.xxx.io" - "--docker.watch" - "--consul" - "--consul.endpoint=consul:8500" - "--consul.prefix=traefik" - "--accesslogsfile=/dev/stdout" - "--debug" networks: - traefik deploy: placement: constraints: - node.role == manager restart_policy: condition: on-failure depends_on: - consul proxy: image: traefik:1.6.3-alpine depends_on: - traefik_init - consul command: - "traefik" - "--consul" - "--consul.watch" - "--consul.endpoint=consul:8500" - "--consul.prefix=traefik" volumes: - /var/run/docker.sock:/var/run/docker.sock networks: - traefik ports: - 80:80 - 443:443 - 8080:8080 deploy: labels: - "traefik.docker.network=infra_traefik" - "traefik.port=8080" - "traefik.tags=monitoring" - "traefik.backend.loadbalancer.stickiness=true" - "traefik.frontend.passHostHeader=true" - "traefik.frontend.rule=Host:proxy.swarm.xxx.io" - "traefik.frontend.auth.basic=admin:$$apr1$$hfqD9TtY$$oGSy9nS." mode: global restart_policy: condition: on-failure placement: constraints: - node.role == manager update_config: parallelism: 1 delay: 10s volumes: - "/var/run/docker.sock:/var/run/docker.sock" networks: traefik: driver: overlay volumes: portainer-data: driver: local consul-data: driver: local traefik-data: driver: local