Using a single Traefik instance to discover multiple Docker hosts

Hello.

I'm trying to figure out how to access services locally across containers in multiple Docker hosts.

Currently, I have traefik running on each Docker machine, while a local instance proxies requests to it.

# Locally-hosted traefik
❯ cat file-provider.yml
http:
  routers:
    vm1:
      rule: "HostRegexp(`{subdomain:[a-z]+}.vm1.net`)"
      service: vm1

  services:
    vm1:
      loadBalancer:
        servers:
          - url: "http://vm1.internal:82"
# vm1.internal traefik
traefik:
  image: traefik
  command:
    - "--api.insecure=true"
    - "--entrypoints.http.address=:80"
    - "--providers.docker.defaultrule=Host(`{{ index .Labels \"com.docker.compose.service\" }}.vm1.net`)"
  ports:
    - 82:80
  volumes:
    - /var/run/docker.sock:/var/run/docker.sock:ro

Since there's too many moving parts, I was wondering if it was possible for a single Traefik instance to discover Docker services for multiple specified hosts.

You use an orchestrator such as Docker Swam, Kubernetes, Marathon. If you not keen on that you can leverage a discovery services like etcd, zookeeper, consul.

Traefik works with many of these.

Just a question more for me but applicable in this situation --
In the static configuration file that is like the following:

providers:
  docker:
    endpoint: "unix:///var/run/docker.sock"
#    endpoint: "tcp://dockerproxy:2375"
    exposedbydefault: false
    watch: true

Could you list multiple tcp endpoints???

I was hoping for something like this:

providers:
  docker-vm1:
    type: docker
    endpoint: “”

  file1:
    type: file-provider
1 Like