Docker Community Forums

Share and learn in the Docker community.

Why docker swarm does not support layer 7 routing?


(Elps) #1

So e.g. service_a should listen on /service_a/:80 , while service_b is listening on /service_b/:80 .

Layer 7 means simple HTTP based routing. As far as I know docker swarm only provides routing on layer 4 (ip:port). HTTP based routing is pretty important and common in mulitple service applications, isn’t it? Am I forced to use 3rd party tools such as HAProxy?

I kind of lack some overview about the technologies and the providers so I am appreciating hints a lot.

Edit: I just found this: https://docs.docker.com/ee/ucp/interlock/usage/context/

It shows that you can use context_root for layer 7 routing. Is this hidden behind a paywal or useable with docker ce as well?

Best regards.


(Metin Y.) #2

You need Docker-EE in order to run UCP. Interlock is an integral part of UCP. The core part is nginx and a sidecar container that listens on the docker events for created/terminated containers to update the nginx configuration on the fly. It is not untypicaly for open sourced products to have versions with extended functionality for paying customers.

If you need Layer7 load balancing, you can either mimic interlock with https://hub.docker.com/r/jwilder/nginx-proxy/ or use Traefic, which is an even nicer solution.

HAProxy and nginx are known to allow SNI TCP Passthrough on layer4 if required.


(Elps) #3

Thanks for the quick reply!


#4

Bear in mind that Docker Swarm is just a container orchestrator and should remain a container orchestrator. Anything over and above that functionality should be provided as third-party or proprietary tooling/plugins.

Check out Traefik if you want an easily-configurable frontend reverse proxy for your applications.


(David Skowronski) #5

Just a quick note on name instead of IP. You can use the name of the container from the docker compose file to talk to other nodes in that docker stack. Multiple instances of the node get a number added to the end I think. It uses the internal subnet. To have a node talk to the outside an Nginx node can be configured. Nginx also can be configured to route the outside world to specific nodes using this same mechanism.