Problems with Docker Swarm and Traefik 2.x

Hello,
I have the following problems maybe someone can help me? Thanks in advance
I try to start a reverse proxy service with the following compose file

version: '3.3'

services:
    reverse-proxy:
     image: traefik:latest
     command:
       - "--api.insecure=true"
       - "--providers.docker=true"
       - "--providers.docker.endpoint=tcp://127.0.0.1:2377"
       - "--providers.docker.swarmMode=true"
     ports:
       - 80:80
       - 8080:8080
     volumes:
       - /var/run/docker.sock:/var/run/docker.sock
     deploy:
        mode: global
        placement:
          constraints:
            - node.role == manager

networks:
   default:
    external:
      name:  imixs-proxy-net

unfortunately the log file reports the following

  • level=error msg="Failed to retrieve information of the docker client and server host: Cannot connect to the Docker daemon at tcp://127.0.0.1:2377. Is the docker daemon running?" providerName=docker,
  • level=error msg="Provider connection error Cannot connect to the Docker daemon at tcp://127.0.0.1:2377. is the docker daemon running?, retrying in 8.304770066s" providerName=docker,

or when I change to " - "--providers.docker.endpoint=tcp://127.0.0.1:2375""

  • level=error msg="Failed to retrieve information of the docker client and server host: Cannot connect to the Docker daemon at tcp://127.0.0.1:2375. Is the docker daemon running?" providerName=docker,
  • level=error msg="Provider connection error Cannot connect to the Docker daemon at tcp://127.0.0.1:2375. is the docker daemon running?, retrying in 8.304770066s" providerName=docker,

I'm not sure which port to use? 2377? My two nodes were included with the following command

  • docker swarm join --token SWMTKN-1-681fxfby12y7a62n6vj890CCCCCC 51.75.YX.ABC:2377

the documentation is different (see atachement) but I gues it should be 2377
Cluster is up and running so i think the nodes can communicate with the master over 2377

from https://docs.traefik.io/providers/docker/

The two services are started with the following commands

  • sudo docker stack deploy -c ./management/traefik/docker-compose.yml reverse-proxy
  • sudo docker stack deploy -c ./apps/whoami/docker-compose.yml whoami

Here is the compose file of the whoami service, which I will use to test if it works

version: '3.3'

services:
  whoami:
    # A container that exposes an API to show its IP address
    image: containous/whoami
    labels:
      - "traefik.http.routers.whoami.rule=Host(`whoami.bpmspace.net`)"
      - "traefik.http.services.whoami.loadbalancer.server.port=8080"

networks:
   default:
    external:
      name:  imixs-proxy-net

But first I have the upper problem, by the way, no matter with which port I try ...

Thanks rob

PS Portainer also runs on the Master.

If you do know know what port to use I suggest removing "--providers.docker.endpoint=tcp://127.0.0.1:2377" line altogether. It's for those who knows what port they want traefik to connect to docker.

Happy new Year

Thanks - i finally got it to run with

version: '3.3'

networks:
 imixs-proxy-net:
   external: true
      
services:
    reverse-proxy:
     image: traefik:latest
     command:
      --providers.docker
      --providers.docker.exposedbydefault=false
      --providers.docker.swarmmode=true
      --entryPoints.http.address=":80"
      --accesslog
      --log.level=DEBUG
      --api=true
      --api.dashboard=true
     ports:
       - 80:80
       - 8080:8080
     volumes:
       - /var/run/docker.sock:/var/run/docker.sock
     deploy:
        mode: global
        placement:
          constraints:
            - node.role == manager
        labels:
          - traefik.enable=true
          - traefik.http.services.justAdummyService.loadbalancer.server.port=1337
          - traefik.http.routers.traefikRouter.rule=Host(`traefik.bpmspace.net`)
          - traefik.http.routers.traefikRouter.service=api@internal
          - traefik.http.routers.traefikRouter.entrypoints=http
     networks:
       - imixs-proxy-net

and whois

version: '3.3'

networks:
 imixs-proxy-net:
   external: true
   
services:
  whoami:
    image: containous/whoami
    deploy:
      labels:
        - traefik.enable=true
        - traefik.http.routers.whoami.rule=Host(`whoami.bpmspace.net`)
        - traefik.http.services.whoami-service.loadbalancer.server.port=80
    networks:
      - imixs-proxy-net

Thanks and goodby

1 Like