dockertraefikswarm

Traefik 2.0 "port is missing" for internal dashboard


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


Solution

  • 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?