Dynamic.yml or labels in docker

I am learning how to use Treafik and what I am stuck on is this:
I have a container (wordpress) that has the routing rule "traefik.http.routers.wordpress.rule=Host(localhost)". My issue is that it seems the docker-compose file will get really hard to read with all the potential rules written as labels. a dynamic yml file seems the way to go but for the life of me I cannot understand how to provide the same function using the yml file. I understand the router rules. but then I don't know how to go from the service entry in the file to the container?
or is the best way to use a bunch of labels for everything? I just feel like a yml file will be laid out in such a way that when I come back to this in 6 months I will be able to peruse the dynamic.yml file and follow the rules.


The main goal of Traefik is to manage dynamic architecture:

  • a container appears, Traefik detect it and create the configuration (based on labels)
  • a container disappears, Traefik detect it and remove the configuration

The file provider breaks this dynamic behavior.

The file provider, for the routing, has been introduced for only old architecture (VMs, bare metal servers, ...)

So to use Traefik with Docker, the labels are the best way.

There are 2 syntaxes for the labels:

With quotes and equal:

    image: traefik/whoami:v1.6.0
      - "traefik.enable=true"
      - "traefik.http.routers.aaa.rule=Host(`whoami.localhost`)"
      - "traefik.http.routers.aaa.entrypoints=websecure"

Without quotes and 2 dots:

    image: traefik/whoami:v1.6.0
      traefik.enable: 'true'

      traefik.http.routers.aaa.rule: Host(`whoami.localhost`)
      traefik.http.routers.aaa.entrypoints: websecure

The second syntax is better for me.

1 Like

I'm also sold on the latter format for labels.


So this is where the latest images are. I was still using the containous/ repo.

1 Like

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