Docker Community Forums

Share and learn in the Docker community.

Using config in docker compose file isn't enough, I have to define the volume in the service as well

docker

(Cafevagrant) #1

For some reason if I remove the volume $PWD/infra/traefik.toml:/traefik.toml I cannot just rely on the config definition even if I change the config file path to $PWD/infra/traefik.toml. I won’t be able to reach the traefik dashboard at the defined Host, traefik.example.com.

I’ve seen other yml examples that only rely on the config definition for the toml file. Any ideas on what I’m doing wrong here?

networks:
  proxy:
    driver: overlay

configs:
  traefik_toml_v2:
    file: ./traefik.toml

services:
  traefik:
    image: traefik:1.5-alpine
    volumes:
    - /var/run/docker.sock:/var/run/docker.sock
    - $PWD/infra/traefik.toml:/traefik.toml
    - $PWD/infra/acme.json:/acme.json
    deploy:
      replicas: 1
      labels:
      - traefik.enable=true
      - traefik.docker.network=proxy
      - traefik.backend=traefik
      - traefik.frontend.rule=Host:traefik.example.com
      - traefik.backend.loadbalancer.sticky=true
      - traefik.frontend.passHostHeader=true
      - traefik.port=8080
      placement:
        constraints:
        - node.role == manager
      restart_policy:
        condition: on-failure
    networks:
    - proxy
    ports:
    - target: 80
      protocol: tcp
      published: 80
      mode: ingress
    - target: 443
      protocol: tcp
      published: 443
      mode: ingress
    - target: 8080
      protocol: tcp
      published: 8080
      mode: ingress
    configs:
    - source: traefik_toml_v2
      target: /etc/traefik/traefik.toml
      mode: 444

(Cafevagrant) #2

It seems to be working after I decided to use an external network instead of one within the stack. Related to this: https://github.com/containous/traefik/issues/2806