Traefik 2.3 does not see my swarm services

Trying to learn traefik. And I get it to work in Docker Swarm.

Traefik starts but it cant see my services:

My traefik.yml file looks this:

################################################################
# API and dashboard configuration
################################################################
api:
  # Dashboard
  #
  #
  dashboard: true
  insecure: true
################################################################
# Docker configuration backend
################################################################
providers:
  docker:
    watch: true
    exposedByDefault: false
    swarmMode: true
################################################################
# Traefik Logging
################################################################
log:
  level: DEBUG

################################################################
# Entrypoint
################################################################
entryPoints:
  web:
    address: ":80"
  websecure:
    address: ":443"

My stack file looks like this:

version: '3'

services:
  traefik:
    # The latest official supported Traefik docker image
    image: traefik:v2.3
    # Enables the Traefik Dashboard and tells Traefik to listen to docker
    # enable --log.level=INFO so we can see what Traefik is doing in the log files
    ports:
      # Exposes port 80 for incomming web requests
      - "80:80"
      - "443:443"
      # The Web UI port http://0.0.0.0:8080 (enabled by --api.insecure=true)
      - "8080:8080"
    volumes:
      # So that Traefik can listen to the Docker events
      - /var/run/docker.sock:/var/run/docker.sock
      - /home/robo/docker-volumes/traefik/traefik-yaml/traefik.yml:/etc/traefik/traefik.yml

# Add the catapp service
  catapp:
     # A Random Cat GIF generator application
     image: mikesir87/cats:1.0
     # We set a label to tell Traefik to assign a hostname to the new service
     labels:
      - "traefik.enable=true"
      - "traefik.http.routers.catapp.rule=Host(`catapp.localhost`)"
      - "traefik.http.routers.catapp.entrypoints=web"
      - "traefik.http.services.catapp.loadbalancer.server.port=5000"

And these are my networks:

Why not use current Traefik version v2.9?

You need to run Traefik on a Docker Swarm manager, put according placement constraints in your docker-compose.yml.

I altered it as sugested and still not seeing my services:

version: '3'

services:
  traefik:
    # The latest official supported Traefik docker image
    image: traefik:v2.9
    # Enables the Traefik Dashboard and tells Traefik to listen to docker
    # enable --log.level=INFO so we can see what Traefik is doing in the log files
    deploy:
      placement:
        constraints:
          - node.role==manager
    ports:
      # Exposes port 80 for incomming web requests
      - "80:80"
      - "443:443"
      # The Web UI port http://0.0.0.0:8080 (enabled by --api.insecure=true)
      - "8080:8080"
    volumes:
      # So that Traefik can listen to the Docker events
      - /var/run/docker.sock:/var/run/docker.sock
      - /home/robo/docker-volumes/traefik/traefik-yaml/traefik.yml:/etc/traefik/traefik.yml
      

# Add the catapp service
  catapp:
     # A Random Cat GIF generator application
     image: mikesir87/cats:1.0
     # We set a label to tell Traefik to assign a hostname to the new service
     labels:
      - "traefik.enable=true"
      - "traefik.http.routers.catapp.rule=Host(`catapp.localhost`)"
      - "traefik.http.routers.catapp.entrypoints=web"
      - "traefik.http.services.catapp.loadbalancer.server.port=5000"

Here's a sample that works for me: You might need to specify a network that Traefik and your app share

version: '3.8'
services:
  flame:
    image: pawelmalak/flame:latest
    container_name: flame
    volumes:
      - /nutanix/flame:/app/data
    ports:
      - 5005:5005
    networks:
      - overlay
    environment:
       - PASSWORD=password
    restart: unless-stopped
    deploy:
      placement:
        constraints:
          - node.role != manager
          - node.labels.location == mesa
      labels:
        - "traefik.enable=true"
        - "traefik.docker.network=overlay"
        - "traefik.http.routers.flame.entrypoints=https"
        - "traefik.http.routers.flame.rule=Host(`dashboard.domain.net`)"
        - "traefik.http.routers.flame.tls=true"
        - "traefik.http.services.flame.loadbalancer.server.port=5005"
        - "traefik.http.services.flame.loadbalancer.server.scheme=http"
        
               
networks:
  overlay:
    external: true
1 Like

That fixed it for me

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.