Traefik not reloading configuration when dynamic file was changed

Hi,

I was trying to follow the docs regarding automatic configuration reload and noticed an issue for which I am not sure if it's isolated case for me or not.

My setup is the following(Pretty much the quick start from docs):

docker-compose.yml:

version: '3.7'

services:
  reverse-proxy:
    image: traefik:v2.0
    ports:
      - "80:80"
      - "8080:8080"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - ./traefik.yml:/etc/traefik/traefik.yml
      - ./dynamic.yml:/etc/traefik/dynamic.yml

  whoami:
    image: containous/whoami
    labels:
      - "traefik.http.routers.whoami.rule=Host(`whoami.docker.localhost`)"

traefik.yml

providers:
  file:
    filename: "/etc/traefik/dynamic.yml"
    watch: true
  docker:
    endpoint: "unix:///var/run/docker.sock"
api:
  insecure: true

dynamic.yml-file I tested with full copy paste from https://docs.traefik.io/reference/dynamic-configuration/file/ but also with random parts from that and verified that it did load them into dashboard just fine when I restarted the container.

My issue starts when I try to modify that dynamic configuration file and it should reload the configuration:

No matter if I modify the file locally outside the container or if I just echo text into the file while being inside container shell the configuration is never reloaded even though I have set the watch setting to true unless I restart the container itself.

Am I doing something horribly wrong somewhere?

Docker Host OS: MacOS(10.14.4)
Docker version: 19.03.1

Hello,

with Docker I recommend to mount a folder instead of a file, because have some issues with fs notify on mounted file.

1 Like

Hey,

I tried that but it has the exact same issue.

Mounted ./config:/etc/traefik and confirmed that the configurations were loaded fine but no matter what I modified inside the container or outside on that dynamic file, it just didn't trigger the reload and i did also check the container logs and no mention of any reloads.

I can reproduce with filename but not with directory.

version: '3.5'

services:

  traefik:
    image: traefik:v2.0.0
    ports:
      - 80:80
    command:
      - --log.level=DEBUG
      - --api
      - --entrypoints.web.address=:80
      - --providers.file.filename=/config/dynamic.yml
      - --providers.docker.exposedbydefault=false
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.traefik.rule=Host(`traefik.docker.localhost`)"
      - "traefik.http.routers.traefik.service=api@internal"
      - "traefik.http.routers.traefik.entrypoints=web"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - ./config/:/config/

Could you give more information about your environment?

Hey,

I decided to try again but this time removed the filename and replaced it with directory and it seems to reload the dynamic config now. I have no idea why filename doesn't work but seems like directory does the same thing which I need for the project I have.

This was the configuration that seems to work but gives no console line or anything that it was reloaded:

providers:
  file:
    directory: /etc/traefik
    watch: true
  docker:
    endpoint: "unix:///var/run/docker.sock"
    watch: true
api:
  insecure: true

So it seems that with filename it refuses to reload anything even with watch enabled but if it just listens the directory it does works as I can see middleware being removed / altered each time I refresh the dashboard after I emptied or modified the dynamic file.

Would have preferred to only watch for that one dynamic file but I guess this works too.

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