Is it possible to load balance the request to two different containers?

Hello everyone.

What I want to do is forward the request from a client to two different containers. I need to let them being seen by a client as only one application.

I know that when I increase the number of replicas for the service, multiple containers will be launched and they will receive the request with Ingress load balancing through the specific port.
But I want to use different images and settings for two container, it means that I can’t scale the containers by setting replica. I think I need to deploy two services, but they can’t share the port of the Swarm cluster at once.

I know that I can do like this by using kubernetes(the combination of service and pod’s label), but is there any way to realize by using Swarm?

Thanks,
Daigo

uhm, what you want is a reverse proxy container that forward the traffic to the target container depending on the context path or a subdomain?

You might want to take a look at Traefik.

1 Like

Definitely sounds like a proxy situation, might I suggest an nginx-proxy to load balance?

2 Likes