Label vs YML Config Setup

I am currently learning how to setup v2 so I can migrate a setup I already have. I see that you can either use labels in the docker compose file to setup things such as routers or put router config inside of a static config file. If you put the configuration inside a static config file, how does it know which container that router is for?

Hello,

The dynamic configuration cannot be define in the static configuration.

Those notions are exactly the same as v1:

The main difference between v1 and v2 about dynamic configuration (outside the content of the configuration) is the capability to reference an element from a provider into another provider. We call that: provider namespace

The goal of Traefik is to manage automatically configuration in a context where containers can appears and disappears (micro-service infrastructure by example), so I recommend to use labels instead of file for Docker based infrastructure.

The file provider, for routers and services, is mainly made for old infrastructure (non-container based) so once again I recommend to not use the file provider to define routers for Docker based infrastructure.

3 Likes