Web / Traefik Interview questions
How do you configure Traefik using Docker labels?
When the Docker provider is enabled, Traefik reads labels attached to each container to build routers, services, and middlewares for that container, so routing configuration lives right next to the service definition.
labels: - "traefik.enable=true" - "traefik.http.routers.myapp.rule=Host(`myapp.example.com`)" - "traefik.http.routers.myapp.entrypoints=websecure" - "traefik.http.routers.myapp.tls.certresolver=myresolver" - "traefik.http.services.myapp.loadbalancer.server.port=8080"
The label namespace follows a consistent pattern: traefik.http.<routers|services|middlewares>.<name>.<option>, which is what lets Docker Compose files fully describe routing without a separate dynamic config file.
Because these labels are read live by the Docker provider, updating them and recreating the container is enough to change routing; there's no separate reload step or config file to keep in sync with what's actually running.
More Related questions...