Traefik not picking up labels for container

I have a working traefik instance running in docker swarm. I have successfully deployed a number of services using docker labels. Trying to add another docker, I have used a working docker-compose file but then updated the settings for the service but traefik is not picking up the new service.

Can anyone help me see what I've done wrong here please?

Docker compose for traefik

services:
  traefik:
    image: "traefik:3.0"
    ports:
      - target: 80
        published: 80
        protocol: tcp
        mode: host
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock:ro"
      - ".:/etc/traefik"
    networks:
      - services
    command:
      - --log.level=DEBUG
      - --log.format=json
      - --api.dashboard=true
      - --accessLog=true
      - --providers.docker=true
      - --providers.docker.exposedbydefault=false # makes it a requirement to have a traefik.enable=true
      - --entrypoints.web.address=:80
      - --providers.docker.httpClientTimeout=300
    deploy:
      mode: replicated
      replicas: 1
      placement:
        constraints: [node.role == manager]
    labels:
      - "traefik.enable=true"
      - "traefik.docker.network=services"
      - "traefik.http.routers.dashboard.rule=Host(`localhost`) && (PathPrefix(`/dashboard`) || PathPrefix(`/api`))"
      - "traefik.http.routers.dashboard.priority=1001"
      - "traefik.http.routers.dashboard.service=api@internal"
      - "traefik.http.routers.dashboard.entrypoints=web"
networks:
  services:
    external: true

docker compose for working service:

services:
  auth:
    build:
      context: ./
      target: auth-base
    volumes:
      - ./config/.env.local:/usr/app/.env.local:r
      - ./config/.env.secrets:/usr/app/.env.secrets:r
      - ./config/.env.common:/usr/app/.env.common:r
      - ./config/.env.auth:/usr/app/.env.auth:r
      - .:/usr/app/:delegated
    networks:
      - services
    ports:
      - "3000"
    environment:
      NODE_ENV: development
      PORT: 3000
    labels:
      - "traefik.enable=true"
      - "traefik.docker.network=services"
      - "traefik.http.routers.auth.rule=Host(`localhost`) && PathPrefix(`/api/auth`)"
      - "traefik.http.routers.auth.priority=1010"
      - "traefik.http.routers.auth.entrypoints=web"
    restart: unless-stopped
    command: npm run dev
networks:
  services:
    external: true

docker compose for the one that traefik isn't seeing:

services:
  lobby:
    build:
      context: ./
      target: lobby-deps
    volumes:
      - ./config/.env.local:/usr/app/.env.local:r
      - ./config/.env.secrets:/usr/app/.env.secrets:r
      - ./config/.env.common:/usr/app/.env.common:r
      - ./config/.env.lobby:/usr/app/.env.lobby:r
      - .:/usr/app/:delegated
    networks:
      - services
    ports:
      - "3000"
    environment:
      NODE_ENV: development
      PORT: 3000
    labels:
      - "traefik.enable=true"

      - "traefik.docker.network=services"

      - "traefik.http.routers.lobby.rule=Host(`localhost`) && PathPrefix(`/`)"
      - "traefik.http.routers.lobby.priority=100"
      - "traefik.http.routers.lobby.entrypoints=web"
    restart: unless-stopped
    command: npm run dev

networks:
  services:
    external: true

Update, there seems to be a misconfigured service somewhere which is mapping the same service to a different hostname (although this service cannot be seen when listing docker ps). When I delete lobby, it reappears in the traefik config.

So now I need to figure out how to de-register that service from the traefik container to see if that resolves the issue.

I wonder whether it is possible for the traefik config to get out of sync with docker itself and whether there is a kick you can give it or whether I delete the config, restart traefik and that sorts it?

Couldnt find the reason why that config was stuck. I guess maybe this is coming from docker being misconfigured somewhere.

Renaming the service to lobbyfe fixed the issue.

In Traefik v3, you need to use providers.swarm to auto configure Swarm services (doc).

Also note that labels need to go inside deploy section for Docker Swarm services.

Compare to simple Traefik Swarm example.

Thank you blue puma - that's useful to know

Can I ask how this relates to my issue specifically?

Traefik is configured without issue on the dev 'swarm'. The swarm configuration (single server) is maybe masking the fact the labels are in the traefik stanza rather than under the deploy stanza specifically? In any case, no issues with traefik itself with the manager and api both working correctly.

You can see the rogue service listed third. Does not appear when doing docker ps. the fourth one is the 'fixed' service which now shows in traefik.

Host(`localhost`) && (PathPrefix(`/dashboard`) || PathPrefix(`/api`))    dashboard@docker
Host(`localhost`) && PathPrefix(`/api/auth`)                             auth@docker
Host(`lobby-blue`)                                                       lobby@docker
Host(`localhost`) && PathPrefix(`/`)                                     lobbyfe@docker
etc etc

I am not deploying my services using docker stack deploy because it complicates my life on localhost. Instead on my dev machine, the services network is attachable and I spin up dev services using docker compose up. As I said, most of the services work fine, it's just lobby that doesn't and that because of this non-existent service.

Feels like this might be a docker issue but I don't know enough about traefik or Go to figure it out. For now I've solved by using a different non-conflicting service name.

You wrote you use Swarm, so I assumed multiple nodes and docker stack deploy use.

Ah. Makes total sense. Thank you