A docker-compose only configuration for Traefik with swarm?

Hi,

Is it possible to configure Traefik with docker swarm using only docker-compose.yml?

I have been getting quite confused following various tutorials and examples. This is what I have so far, I can connect to the dashboard but it does not pick up any deployed services:

version: "3.3"

services:
  traefik:
    image: traefik:v2.6
    ports:
      - 80:80
      - 8080:8080
    networks:
      - traefik-net
    command:
      - --api.insecure=true
      - --api.dashboard=true # see https://docs.traefik.io/v2.0/operations/dashboard/#secure-mode for how to secure the dashboard
      - --api.debug=true # enable additional endpoints for debugging and profiling
      - --log.level=DEBUG # debug while we get it working, for more levels/info see https://docs.traefik.io/observability/logs/
      - --providers.docker=true
      - --providers.docker.swarmMode=true
      - --providers.docker.endpoint='unix://var/run/docker.sock'
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    deploy:
      placement:
        constraints:
          - node.role == manager

networks:
  traefik-net:
    driver: overlay

I have a test service (from a tutorial I found), which has this docker-compose.yml

version: "3.3"

services:

  books:
    image: mlabouardy/books-api
    networks:
      - traefik-net
    deploy:
      placement:
        constraints:
          - node.role == worker
      labels:
          - traefik.http.routers.books.rule=PathPrefix('/books')
          - traefik.http.services.books.loadbalancer.server.port=5000

networks:
  traefik-net:
    driver: overlay

Can anyone see what I'm doing wrong here? Any help would be most appreciated.

Cheers

Rich

Your books app isn’t exposing port 5000?
Just for test try adding the label - "traefik.enable=true" to your app container.
You haven’t set any static config elements via env vars have you? It appears setting static config in two places is not supported.
You are missing - "traefik.http.routers.books.service=books this is needed I think before you can use …services.books….

I am new to traefik, so take my suggestions with grain of salt.