# Central Traefik to multiple vm's with dockers

**URL:** <https://community.traefik.io/t/central-traefik-to-multiple-vms-with-dockers/24547>\
**Category:** Traefik v3 (latest)\
**Tags:** docker\
**Created:** [September 24, 2024, 6:10pm UTC](https://community.traefik.io/t/central-traefik-to-multiple-vms-with-dockers/24547 "2024-09-24T18:10:56Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![creamers](https://avatars.discourse-cdn.com/v4/letter/c/8baadc/32.png) [@creamers](https://community.traefik.io/u/creamers)\
**Post date:** [September 24, 2024, 6:10pm UTC](https://community.traefik.io/t/central-traefik-to-multiple-vms-with-dockers/24547/1 "2024-09-24T18:10:56Z")

</div>

Hi,

Been looking to find a solution and don't think it's possible but hope it is.

Can Traefik be used as central loadbalancer with multiple hosts with docker?  
Meaning I don't want to run swarm/k8s, but use Traefik to balance traffic like:

[abc.domain.com](http://abc.domain.com) to container with label abc that runs on hostA  
and  
[def.domain.com](http://def.domain.com) to container with label def that runs on hostB

(It must be possible to stop container abc and start it on hostB and Traefik should autodiscover this and forward traffic)  
Can this be done using Traefik CE?

Funny part, chatgpt keeps telling me that it's possible but can't find any info on it.  
_Yes, **Traefik** can indeed work with **Direct IP Routing** to forward traffic between a central Traefik instance and multiple Docker hosts, without requiring Docker Swarm or Kubernetes. This setup relies on Traefik connecting to the Docker API on each host (for example, via TCP) to retrieve information about running containers, and then routing traffic based on the IP addresses and ports exposed by those containers._

---

<div class="post-metadata">

**Author:** ![bluepuma77](https://avatars.discourse-cdn.com/v4/letter/b/a9adbd/32.png) [@bluepuma77](https://community.traefik.io/u/bluepuma77)\
**Post date:** [September 24, 2024, 7:52pm UTC](https://community.traefik.io/t/central-traefik-to-multiple-vms-with-dockers/24547/2 "2024-09-24T19:52:14Z")

</div>

The standards are k8s or Docker Swarm to work with multiple nodes. Without those, how do you want to connect the nodes among each other? Even if you would connect to different Docker sockets, how do you want to connect to the Docker container target IPs?

Maybe a project like [traefik-kop](https://github.com/jittering/traefik-kop) can help. But be aware it has only 3 developers, if they lose interest you might get stuck with a unmaintained piece of software, with unfixed bugs and security holes.

We use good old Docker Swarm, works for a few nodes, even though development is really slow. But we get bug fixes.

---

<div class="post-metadata">

**Author:** ![creamers](https://avatars.discourse-cdn.com/v4/letter/c/8baadc/32.png) [@creamers](https://community.traefik.io/u/creamers)\
**Post date:** [September 24, 2024, 9:10pm UTC](https://community.traefik.io/t/central-traefik-to-multiple-vms-with-dockers/24547/3 "2024-09-24T21:10:45Z")

</div>

I thought if it would still discover it on nodeA , then a translation could be that it knows nodeA external ip en map the port accordingly assuming the docker network is host .  
But thanks for clarifying.

---

<div class="post-metadata">

**Author:** ![bluepuma77](https://avatars.discourse-cdn.com/v4/letter/b/a9adbd/32.png) [@bluepuma77](https://community.traefik.io/u/bluepuma77)\
**Post date:** [September 25, 2024, 5:47am UTC](https://community.traefik.io/t/central-traefik-to-multiple-vms-with-dockers/24547/4 "2024-09-25T05:47:32Z")

</div>

The standard `providers.docker` uses the container internal IPs, assuming Traefik and target can connect within Docker.

---

<div class="post-metadata">

**Author:** ![creamers](https://avatars.discourse-cdn.com/v4/letter/c/8baadc/32.png) [@creamers](https://community.traefik.io/u/creamers)\
**Post date:** [September 25, 2024, 6:11am UTC](https://community.traefik.io/t/central-traefik-to-multiple-vms-with-dockers/24547/5 "2024-09-25T06:11:20Z")

</div>

Was thinking about something like this:

[providers.docker]  
endpoint = "tcp://server-a-ip:2375"  
exposedByDefault = false

[providers.docker]  
endpoint = "tcp://server-b-ip:2375"  
exposedByDefault = false

---

<div class="post-metadata">

**Author:** ![bluepuma77](https://avatars.discourse-cdn.com/v4/letter/b/a9adbd/32.png) [@bluepuma77](https://community.traefik.io/u/bluepuma77)\
**Post date:** [September 25, 2024, 5:34pm UTC](https://community.traefik.io/t/central-traefik-to-multiple-vms-with-dockers/24547/6 "2024-09-25T17:34:22Z")

</div>

You can only have one provider if a kind.

And as stated, the Docker provider returns the Docker-internal IP, which can be used inside a Docker network.

When using multiple nodes, your need Docker Swarm for an Docker overlay network spanning multiple nodes.

---

<div class="post-metadata">

**Author:** ![Kibukx](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/kibukx/32/9757_2.png) [@Kibukx](https://community.traefik.io/u/Kibukx)\
**Post date:** [December 28, 2024, 8:12pm UTC](https://community.traefik.io/t/central-traefik-to-multiple-vms-with-dockers/24547/7 "2024-12-28T20:12:56Z")

</div>

I’m also stuck with this as well. I use terraform to deploy all of my services on different hosts and wanted to have a centralized traefik instance to managed my home lab instead of having to add traefik to each VM.

Another approach I’m looking into is using Consul Catalog provider but this adds more overhead I think (new to consul). I believe I would need to deploy a single consul server, 1 consul client for each host and then determine how to register the services. Their seems to be a Registrator tool/image but not sure if this is still viable or not, posts that I have seen about this are 8+ years old.

Maybe the next big leap would be to go the K8S route ⌛

---

<div class="post-metadata">

**Author:** ![bluepuma77](https://avatars.discourse-cdn.com/v4/letter/b/a9adbd/32.png) [@bluepuma77](https://community.traefik.io/u/bluepuma77)\
**Post date:** [December 28, 2024, 8:52pm UTC](https://community.traefik.io/t/central-traefik-to-multiple-vms-with-dockers/24547/8 "2024-12-28T20:52:45Z")

</div>

Try Docker Swarm first, I think it's a lot easier than k8s.

Check [simple Traefik Swarm example](https://github.com/bluepuma77/traefik-best-practice/tree/main/docker-swarm-traefik).

---

<div class="post-metadata">

**Author:** ![yala](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/yala/32/10371_2.png) [@yala](https://community.traefik.io/u/yala)\
**Post date:** [May 14, 2025, 2:12pm UTC](https://community.traefik.io/t/central-traefik-to-multiple-vms-with-dockers/24547/9 "2025-05-14T14:12:17Z")

</div>

> [@bluepuma77](#):
>
> When using multiple nodes, your need Docker Swarm for an Docker overlay network spanning multiple nodes.

This is not true for cases, where a central Traefik Container on Incus is deemed to proxy multiple Docker Engines in nested Incus System Containers running Docker, for example.
