Using Traefik with a Docker Backend to proxy to Jenkins
This is a simple configuration of Traefik that would only be used in a very niche case where the Traefik service and the Docker service were run on the same host.
Traefik will be started with a minimal configuration defining entrypoints and the docker backend.
Traefik frontends and backends will be configured from the values in Docker labels.
Traefik and dynamic configurations
It is important to know that Traefik, by design, is intended to take its configuration from some dynamic source.
Traefik is intended to be a cloud-friendly proxy where the configuration of frontends and backends comes from a service provider like Docker.
Using Traefik means configuring entrypoints, the dashboard, and wiring Traefik up to the service provider.
It is possible to have manually configured frontend/backend rules within the configuration file, but in that scenario the config file becomes the service provider.
The configuration file as a service provider is not enabled by default and requires the [file] configuration command to enable it.
Just like placing [docker] enables the docker service provider, [file] enables the config file service provider for frontend/backend rules.
Without the [file] command in the example below, the [frontends] and [backends] configurations within the traefik.toml would be ignored completely.
Create Traefik configuration file
Start Traefik Docker Container
- Defining the frontend and backend as Traefik tags in the docker container labels allows the Traefik configuration to be created dynamically based on what Docker containers are running.
- The traefik.frontend.entryPoints tag is a comma separated list.
- GOTCHA: Mind the camelCase on the traefik.frontend.entryPoints label.
Having the entryPoints tag be lowercase instead of camelCased will cause the tag to be ignored.
View the Traefik setup in the dashboard after starting the
- Once both the labeled Docker container and Traefik have been started up, the frontend and backend rules, which take their configuration from the Docker labels, will be viewable within the dashboard.