Docker Community Forums

Share and learn in the Docker community.

Question: tie services to the same swarm node (but not to a particular one)


(Ajunglsy) #1

Dear all,
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:

  1. a server component (1 container)
  2. first application node (1 container)
  3. first logfile processor (1 container)
  4. second application node (1 container)
  5. 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
Andreas


(Ajunglsy) #2

Okay, looks as if it is not possible. I was told, that it will work with Kubernetes, but not with Swarm Mode. Will try to find a solution outside of docker.