From what I can see it goes like this:
docker-traefik.yml
:
version: '3'
services:
traefik:
image: traefik
command: --docker # enable Docker Provider
# use Docker Swarm Mode as data provider
--docker.swarmmode
ports:
- "80:80"
volumes:
# for it to be able to listen to Docker events
- /var/run/docker.sock:/var/run/docker.sock
docker-whoami.yml
:
version: '3'
networks:
traefik_default:
external: true
services:
whoami:
image: containous/whoami
networks:
# add to traefik network
- traefik_default
deploy:
labels:
# whoami is on port 80
- "traefik.port=80"
# whoami is on traefik_default network
- "traefik.docker.network=traefik_default"
# when to forward requests to whoami
- "traefik.frontend.rule=Host:example.com"
Let me quote the documentation here:
Required labels:
traefik.frontend.rule
traefik.port
- Without this the debug logs will show this service is deliberately filtered out.traefik.docker.network
- Without this a 504 may occur....
traefik.docker.network
Overrides the default docker network to use for connections to the container. [1]
traefik.port=80
Registers this port. Useful when the container exposes multiples ports.
But why can't it just take the exposed ports for a default value of traefik.port
? And from what I can see it works without traefik.docker.network
(that is, if traefik_default
is the first service's network). When do I get 504's?