Traefik's Getting Started guid is difficult to follow in any step by step fashion. It has the following problems:
- Getting Started suggests running
traefik
as a command, but no commands can be run on thetraefik
image and you must instead usetraefik:alpine
, even to shell into the container withdocker exec -it ...
. - Getting Started makes hardly any mention of a
traefik.toml
file. - #1 makes a new reader confused as to weather traefik is intended to be run as a container that automatically updates per newly deployed containers like jwilder's nginx proxy or if it's intended to be run on a docker host.
Their original docker-compose.yml
file looks like this:
version: '3'
services:
reverse-proxy:
image: traefik # The official Traefik docker image
command: --api --docker #--consul --consul.endpoint=127.0.0.1:8500 # Enables the web UI and tells Traefik to listen to docker
ports:
- "80:80" # The HTTP port
- "8080:8080" # The Web UI (enabled by --api)
volumes:
- /var/run/docker.sock:/var/run/docker.sock # So that Traefik can listen to the Docker events
whoami:
image: containous/whoami # A container that exposes an API to show its IP address
labels:
- "traefik.frontend.rule=Host:whoami.docker.localhost"
Then you can run it with:
docker-compose up -d reverse-proxy
This is fine and you can add new services here and specify new labels like the one above, i.e. traefik.frontend.rule=Host:whoami-other.docker.localhost
.
You can test this with curl, specifying the host heading like so:
curl -H Host:whoami.docker.localhost http://127.0.0.1
Issue 1)
Line 5 must be changed to use the image traefik:alpine
.
image: traefik:alpine # The official Traefik docker image
You can now actually docker exec
this container. You can only use sh
(not /bin/bash
) on the alpine image. We can now do the following:
docker exec -it traefik_reverse-proxy_1 sh
docker exec -it traefik_reverse-proxy_1 traefik --help
Issue 2)
From the default docker-compose.yml
, there is no mention of a traefik.toml
file. Even if I docker-compose up -d [some_new_service]
and can reach those services, shelling into the container has no traefik.toml
file. It's nowhere in the container, despite that per the bottom of Basics, it says looks for it default locations such as /etc/traefik/
and $HOME/.traefik/
and .
or the working directory. Is this referring to the host or the container? In the container I run grep
find
and only see the binary:
/ # find / | grep traefik
/usr/local/bin/traefik
Is traefik storing my services configuration in memory?
The next logical page in the documentation (Basics), immediately starts detailing configuration of the traefik.toml
, but I have to such file to experiment with.
I had to to back to Getting Started read at the bottom of that page to find that using a static traefik.toml
file must be specified in a volume when they suggest using their official image and running like this:
docker run -d -p 8080:8080 -p 80:80 -v $PWD/traefik.toml:/etc/traefik/traefik.toml traefik
So with this, I change the volumes
section in the original docker-compose.yml
under the service reverse-proxy
to use something similar:
volumes:
- /var/run/docker.sock:/var/run/docker.sock # So that Traefik can listen to the Docker events
- $PWD/traefik.toml:/etc/traefik/traefik.toml
Even with this, I don't have a base traefik.toml
file to even use (there isn't even one in the examples folder of their GitHub). I had to go find one, but wasn't even sure how it would apply to the existing configuration of services I had running (i.e. whoami
and/or whoami-other
). Finally, running find / | grep traefik
on the container shows the same traefik.toml
file in /etc/traefik/traefik.toml
, but it has no mention of the services (which I can still reach with curl -H Host:whoami.docker.localhost http://127.0.0.1
from my docker host). Where is the configuration then?