Static config in traefik.yml vs docker-compose.yml

Static config goes into traefik.yml or command. Dynamic config in a separate file using provider.file or labels using provider.docker.

Note that static can only be loaded with one method, you can’t use both in parallel.

Having it all in docker-compose.yml makes manual handling a bit easier, because you only need a single file. It’s also easier when using Docker Swarm with multiple nodes, don’t need to distribute additional files. And for tutorials it’s mostly in one file so it’s easier for the reader, just needing to create a single and not multiple files.

Separate files can be considered a bit cleaner, may even be necessary for things that can’t be configured with Docker labels (like loadbalancer.servers.url and custom TLS certs), as labels do not support the full set of options (file reference, label reference).

So it’s up to your personal preference or the setup requirements.

1 Like