Traefik simply ignores "labels" configuration.
Following Traefik's main documentation page, we can simply do:
#docker-compose.yml
version: '3'
services:
traefik:
image: traefik # The official Traefik docker image
command: --api --docker # Enables the web UI and tells Træfik to listen to docker
ports:
- "80:80" # The HTTP port
- "8080:8080" # The Web UI (enabled by --api)
volumes:
- ./docker.sock:/var/run/docker.sock # So that Traefik can listen to the Docker events
whoami:
image: emilevauge/whoami # A container that exposes an API to show its IP address
labels:
- "traefik.frontend.rule=Host:whoami.docker.localhost"
Then, running docker-compose should be enough (without traefik.toml file):
docker-compose up -d
Results in the expected:
Starting test_traefik_1 ... done
Starting test_whoami_1 ... done
But unfortunately, Traefik's dashboard displays nothing:
No providers found
What have I tried to do:
- To use also another labels notation:
labels: traefik.backend: "whoami" traefik.frontend.rule: "Host:whoami.docker.localhost"
- To follow this guide.
- To remove "version: '3'", and also changing it to "version: '3.3'".
- To run
$env:DOCKER_HOST="npipe:////./pipe/docker_engine"
or$env:DOCKER_HOST="tcp://localhost:2375"
on Powershell. - To set npipe instead of unix socket:
volumes: - type: npipe source: ./pipe target: /pipe/docker_engine
Nothing works.
Right now, the only way I can see something in the dashboard, is by adding this line to Traefik volumes: "- ./traefik.toml:/traefik.toml", while creating "traefik.toml" file with [file] configurations. I don't want to have this file. I want to have the control inside the "lables" inside docker-compose.yml.
It'll also be nice to know when should I use the traefik.toml file, as opposed to setting lables inside docker-compose.yml. I did not see any information on that.
Edit: docker logs of traefik shows UNIX socket is in use:
time="2018-07-23T10:55:38Z" level=error msg="Failed to retrieve information of the docker client and server host: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?"
time="2018-07-23T10:55:38Z" level=error msg="Provider connection error Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?, retrying in 13.276739006s"
Docker-compose should use npipe protocol on Windows by default, but it doesn't. Trying to set the Windows' pipe explicitly, to take place instead of the UNIX socket (using npipe of the long syntax):
#docker-compose.yml
version: '3.2'
services:
traefik:
image: traefik
command: --api --docker
ports:
- "80:80"
- "8080:8080"
volumes:
- type: npipe # here we are
source: ./pipe
target: /pipe/docker_engine
But still the logs shows:
time="2018-07-23T10:57:18Z" level=error msg="Provider connection error Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?, retrying in 4.166259863s"
time="2018-07-23T10:57:23Z" level=error msg="Failed to retrieve information of the docker client and server host: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?"