Issues with the Docker Provider

[global]
  checkNewVersion = false
  sendAnonymousUsage = false

[entryPoints]
  [entryPoints.websecure]
    address = ":443"
    [entryPoints.websecure.http]
      tls = {  }

  [entryPoints.web]
    address = ":80"
    [entryPoints.web.http]
      [entryPoints.web.http.redirections]
        [entryPoints.web.http.redirections.entryPoint]
          to = "websecure"
          scheme = "https"
          permanent = true
          priority = 1

[log]
  level = "DEBUG"
  filePath = "./log/traefik.json"
  format = "json"
  maxSize = 100
  maxAge = 30

[accessLog]
  filePath = "./log/access.log"
  format = "json"
  bufferingSize = 100

[api]
  dashboard = true

[providers]
  [providers.file]
  filename = "./dynamic/conf.toml"
  watch = true

  [providers.docker]
    swarmMode = true
    endpoint = "unix:///var/run/docker.sock"
    exposedByDefault = false
    network = "public_network"
    watch = true

[certificatesResolvers.letsencryptresolver.acme]
  email = "admin@test.com"
  storage = "./letsencrypt/acme.json"
  [certificatesResolvers.letsencryptresolver.acme.httpChallenge]
    entryPoint = "web"

This is my Traefik configuration in version 2.11.2.

In my portainer stack I configured the following tags:

        labels:
          - 'traefik.enable=true'
          - 'traefik.docker.network=public_network'
          - 'traefik.http.routers.portainer.rule=Host(`portainer.domain.com`)'
          - 'traefik.http.routers.portainer.entrypoints=websecure'
          - 'traefik.http.routers.portainer.priority=1'
          - 'traefik.http.routers.portainer.tls.certresolver=letsencryptresolver'
          - 'traefik.http.routers.portainer.service=portainer'
          - 'traefik.http.services.portainer.loadbalancer.server.port=9000'

By running traffic inside a container with the aforementioned settings, you can access the perfect domain. But when I run the traefik binary, outside the container, with the same settings, I get Gateway time-out Error code 504 on the page.

But, I also enabled the file provider and the routers and services I configured in the file work perfectly, but the docker swarm one doesn't.

I imagine it's a network problem. I searched the logs but didn't find any errors.

Has anyone experienced this and have any ideas on how to resolve it?

Isn’t providers.swarm new in Traefik v3?

You can’t use Traefik outside Docker with Docker (Swarm) Configuration Discovery, as Traefik will try to connect via IPs inside an implicit or explicit Docker Network, to which non Docker apps have no access.

1 Like

Thanks for your response.

Traefik was designed to be used outside of Docker. I've been using it for a while with Docker. But when I enabled swarm mode I had this problem.

With Docker Swarm, we use a Docker Overlay Network and Traefik within container.

Check simple Traefik Swarm example.

1 Like