Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix the issue "Filtering container with empty frontend rule" when running Traefik in Docker Swarm

Traefik is not creating the front-ends nor the back-ends when running in a Docker Swarm cluster with more than one machine.

I created a Docker Swarm on my MacBook (OS version: 10.14.2 (18C54)) by following this tutorial: https://docs.docker.com/get-started/part4/. The docker-machine on my laptop has the version 0.14.0, build 89b8332 and the docker engine running on the VMs has the version 18.09.1, build 4c52b90. Here's a summary of the machines created:

docker-machines

Once the machines were up and running and the swarm was created, I deployed the following stack in my swarm:

version: '3.4'

services:
  api_gateway:
    image: traefik
    command: --api \
      --docker \
      --docker.swarmmode \
      --docker.watch \
      --logLevel=DEBUG
    ports:
      - "80:80"
      - "443:443"
      - "8080:8080"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    networks:
      - external
      - internal
    deploy:
      placement:
        constraints: [node.role==manager]
  redis:
    image: redis:latest
    command: ["redis-server", "--appendonly", "yes"]
    volumes:
      - redis:/data
    networks:
      - internal
    deploy:
      placement:
        constraints: [node.role==worker]
  nginx-test:
    image: valian/nginx-test-page
    labels:
      - "traefik.frontend.rule=Host:api.local.mydomain.com"
    depends_on:
      - redis
    networks:
      - external
      - internal
    deploy:
      placement:
        constraints: [node.role==worker]
networks:
  external:
    driver: overlay
    external: true
  internal:
    driver: overlay
volumes:
  redis:

The screenshot below shows the services running and the cluster visualizer for the swarm:

portainer-services

portainer-cluster

As far as I understand, Traefik should have discovered the service nginx-test, then created the front-end and back-end for it. Here's a scrennshot of the Traefik dashboard:

traefik-dashboard

It seems that the api_gateway service (Traefik) is not able to identify the frontend rule defined for the nginx-test service, as you can on the log below:

2019-02-06T09:04:37.139463121Z time="2019-02-06T09:04:37Z" level=debug msg="Filtering container with empty frontend rule webserver_nginx-test.1 "

Am I missing something on the Traefik setup? Is there another way to set it up when running the reverse proxy in a Docker Swarm cluster?

like image 487
João Bentes Avatar asked Jan 20 '26 13:01

João Bentes


1 Answers

With Swarm, the labels section must define in the deploy section.

https://docs.traefik.io/configuration/backends/docker/#using-docker-with-swarm-mode

version: "3"
services:
  whoami:
    deploy:
      labels:
        traefik.docker.network: traefik
like image 183
ldez Avatar answered Jan 23 '26 20:01

ldez