Transfer from command section in composer file to traefik.yml fails

Hi.
I've made a working docker-compose.yml with a command section for traefik:

version: "3"

services:
  traefik:
    image: "traefik:2.10"
    container_name: "traefik"
    command: 
      - "--api.insecure=true"
      - "--providers.docker=true"
      - "--providers.docker.exposedbydefault=false"
      - "--entrypoints.web.address=:80"
    ports:
      - "80:80"
      - "8080:8080"
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock:ro"

This works and I can connect to the dashboard.
Then I split the static configuration into the traefik.yaml:

api:
  dashboard: true
  insecure: true

entryPoints:
  web:
    address: ":80"

providers:
  docker:
    exposedByDefault: false
    endpoint: "unix:///var/run/docker.sock"

and removed it from the compose file:

version: "3"

services:
  traefik:
    image: "traefik:2.10"
    container_name: "traefik"

    ports:
      - "80:80"
      - "8080:8080"
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock:ro"

And now, after rebuilding the container I can't reach the traefik dashboard. I have reduced this example to the minimum to find my mistake. With services those would result in a 404 after using the traefik.yml.
Why is the traefik.yml not working?
How could I find out?
Thanks, Ejoo

Should you not bind mount the traefik.yml file into the container for Traefik to be able to read it?

That would explain it. I have never found anything about that. What directory in the traefik client?
I have found this:
https://doc.traefik.io/traefik/getting-started/configuration-overview/

At startup, Traefik searches for static configuration in a file named traefik.yml (or traefik.yaml or traefik.toml) in:

  • /etc/traefik/
  • $XDG_CONFIG_HOME/
  • $HOME/.config/
  • . (the working directory).

So I will try one of these folders inside the container.

Well, that worked, I have added the last three lines. Thank you very much!

version: "3"

services:
  traefik:
    image: "traefik:2.10"
    container_name: "traefik"
    ports:
      - "80:80"
      - "8080:8080"
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock:ro"
      - type: bind
        source: ./traefik.yml
        target: /etc/traefik/traefik.yml

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.