Docker Community Forums

Share and learn in the Docker community.

Active/Passive replicas

Hi,
I have several services deployed in containers with Docker Swarm, and each service is deployed at least on 2 instances with :

deploy:
	mode: replicated
	replicas: 2

and everything is working fine.
Now, for one of these services, I would like to have an active / passive mode, i.e. I would like the first instance to run but not the second, and the second runs only if there is a problem with the first instance (for example, shutdown of the VM which hosts the first instance).
Is this possible ?
If not, alternatively, is it possible to deploy the 2 instances ot the same service with 2 different configurations ?
Thank you !
Regards

Just set replicas to 1?
Swarm will try to honor that always, so if one breaks down, another one starts.

If that isnt want you want, and you actually want an active standby, maybe look into loadbalancing, like traefik to see if it can WRR 100% to one node or something like that, docker swarm cant do this by itself.

For the service that I would like in active / passive mode, it does not receive any request, it’s an autonomous service which runs regularly with Spring-Batch / Quartz.
Indeed, I could set the number of replicas to 1, but in this case, is it possible to set up a preferred node so that the service is always deployed on this node, except if a problem occurs on the node ? because the Quartz job can process input files provided in a dedicated directory by my customer and he would have to be able to always copy the input files on the same server (except in case of a problem).

This is not possible on swarm, maybe its possible on k8s instead.