1

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?

Community
  • 1
  • 1
x-yuri
  • 16,722
  • 15
  • 114
  • 161

1 Answers1

0

But why can't it just take the exposed ports for a default value of traefik.port?

If ur container has 3 or 4 exposed ports, which should traefik use? So who saying to traefik, which of these ports the right one? So you do - with traefik.port. Where is the problem to use the default port of your configured service?

U should expose 80, 443 and 8080 - so 80 and 443 for http/https webpages and 8080 for traefik dashboard. If u dont wanna use the dashboard, u dont need to expose 8080.

And i dont see any network configured @ traefik in your composer file - should this have no network? Ur service and traefik need to be in the same network. Otherwise traefik cant reach ur service and forward.

Also where are the endpoints?

Fyndor
  • 49
  • 1
  • 8
  • But it somehow figures out the network if `traefik.docker.network` is not specified. Why can't it do so with `traefik.port`? Then, read the question carefully. It says "basic configuration." Meaning settings without which it doesn't work. As such, I need to expose only port 80. Also, take a closer look, they're on the same network. Just run those two `yaml` files and see for yourself. – x-yuri Jun 26 '19 at 05:47