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 to container with label abc that runs on hostA
and
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.
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 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.
1 Like
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.
The standard providers.docker
uses the container internal IPs, assuming Traefik and target can connect within Docker.
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
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.
1 Like