5

I'm trying to use traefik 2.0 (!) in docker swarm mode. This is my stack:

version: '3.7'
services:
  traefik:
    image: traefik:latest
    ports:
      - 80:80
      - 443:443
    deploy:
      replicas: 1
      placement:
        constraints:
          - node.role == manager
        preferences:
          - spread: node.id
      labels:
        - traefik.enable=true
        - traefik.http.routers.traefikRouter.rule=Host(`127.0.0.11`)
        - traefik.http.routers.traefikRouter.service=api@internal
        - traefik.http.routers.traefikRouter.entrypoints=http
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    command: >
      --providers.docker
      --providers.docker.exposedbydefault=false
      --providers.docker.swarmmode=true
      --entryPoints.http.address=":80"
      --entryPoints.https.address=":443"
      --accesslog
      --log.level=DEBUG
      --api=true
      --api.dashboard=true
    networks:
      - traefik-public

  whoami:
    image: containous/whoami
    deploy:
      replicas: 2
      labels:
        - traefik.enable=true
        - traefik.http.services.whoami.loadbalancer.server.port=80
        - traefik.http.routers.whoami.rule=Host(`127.0.0.12`)
        - traefik.http.routers.whoami.service=whoami
        - traefik.http.routers.whoami.entrypoints=http
    networks:
      - traefik-public

# Run on Host: docker network create --driver=overlay traefik-public
networks:
  traefik-public:
    external: true

Access to http://127.0.0.12/ works, I see the whoami page. Access to http://127.0.0.11/ or http://127.0.0.11/dashboard/ should show traefiks internal dashboard, if I read the docs right. But I get traefiks 404.

The docker service log shows one error:

level=error msg="port is missing" container=traefik-traefik-z8kz9w91yw7pm6tp5os5vxrnv providerName=docker

What's the Problem? I suspect it's missing a port for the service api@internal... But that's its internal service - I can't configure that?!

Any ideas? Thx

xsrf
  • 564
  • 5
  • 18

2 Answers2

20

Okay, just adding a dummy service port to the labels works

      labels:
        - traefik.enable=true
        - traefik.http.services.justAdummyService.loadbalancer.server.port=1337
        - traefik.http.routers.traefikRouter.rule=Host(`127.0.0.11`)
        - traefik.http.routers.traefikRouter.service=api@internal
        - traefik.http.routers.traefikRouter.entrypoints=http

I was struggling with traefik for more than 24h now... This can't be the solution, right? Guess I have to report this as an error. Can someone confirm that this is not how it should work?

xsrf
  • 564
  • 5
  • 18
  • 2
    Can you explain why you think this is how it should work? For me this is clearly an error. You should not have to declare a service if you refer to one that already exists. – xsrf Oct 27 '19 at 17:59
  • I've reported the issue: https://github.com/containous/traefik/issues/5732 – xsrf Oct 28 '19 at 06:41
  • 1
    It is a really painful bug. i wanted to host traefik on macvlan network and traefik container don't track the port automatically on macVlan mode. your solution worked for me after wasting 3 hours. Thank you – Micheal Choudhary Mar 06 '21 at 12:27
  • Ha. This is a daft solution, but dagnammit it still works! :) v2.10 but using network_mode: host instead of swarm – Froosh Jul 14 '23 at 11:34
  • Thank you. I was struggling with swarm mode and the acme challenge was not started until i added the dummy service. How can this still be an issue? It took me nearly 3 hours to find this. I got "404 page not found" when trying to access any subdomain. – Dominik S. Aug 15 '23 at 21:31
-1

I'm still seeing this issue today:

Fix is solving it:

- traefik.http.services.justAdummyService.loadbalancer.server.port=1337
Drallas
  • 1
  • 1