I already searched the internet and also checked the docker compose v3 file reference (placement constraints and so on), but did not find a solution for the following scenario:
We have a docker stack consisting of 5 services, each of them running exactly one container. The services are:
- a server component (1 container)
- first application node (1 container)
- first logfile processor (1 container)
- second application node (1 container)
- second logfile processor (1 container)
Environment is a cluster based on docker swarm mode, currently runnign docker-ce 18.03.1, but we’re about to migrate to docker-ee. OS is ubuntu linux.
The stack basically works, we can deploy it and use the application. But due to a very special storage performance issue, I have the following question:
Is it possible to make sure that the application node and its logfile processor always run on one docker swarm node? It can be any of my swarm nodes, but these two containers always have to run on the same node. Docker is allowed to move them to another node in case one swarm node fails, but these 2 containers always have to go to the same node.
I could of course bind them to a particular host (using the “hostname” placement constraint), but I don’t want to do that, because in this case both services would be unavailable if this host fails. That’s not what I want to reach. I also thought about a soution using tags (tagging the hosts), but I can’t find one…
Let me know, if the explanation is to confusing…
Thank you very much in advance and best regards