Understanding difference between labels in a container vs defining in the config.yml

I'm new to Traefik and I'm trying to understand the difference between these two concepts.

If I use labels on a container does that mean I don't need to include that container in the config.yml file? Or am I supposed to have this information in both places?

I've experimented with a container with just using labels and it shows up in Traefik with Docker as the provider.

Then I removed the labels from the container but kept it in same Traefik network. Only providing information via the config.yml in the Traefik container this shows only a single container entry with the provider as a file.

If I use both the labels on the container and include the container in the config.yml I have 3 entries for the container 2 for docker and 1 for file.

What is the proper way to configure for Traefik?


Traefik has been made to handle dynamic infrastructures like Docker: a container can appear or disappear.

There are several ways to handle the routing: labels, files, tags, ...

In Traefik, the routing configuration is called dynamic configuration.

When you are using Docker the right way is to use labels because the labels are related to a container, so if a container appears or disappears the configuration is automatically updated.

The files (through what we call the file provider) to define the dynamic configuration have been made mainly to handle "old-style" infrastructures like VM or bare metal.

So if I understand correclty I would use "labels" for containers only and I would use the config.yml for external services I want to proxy (e.g., VM, Rpi, server, etc.)?

Yes, for Docker you will have to set labels (it's a Docker notion), and files for VM and bare metal.

There are 2 types of configurations in Traefik:

Thank you for the quick replies this was very helpful!

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