How do I prevent service A from being placed in the same node as service B in Docker Swarm?

HOW TO -️ October 18, 2021

From the docs, I could only find information about placement restrictions based on node attributes, likes labels and its role. However, I couldn't find how to configure placement based on the services already running on a given node.

How can I do that?

Answer

Why can't your two services be run on the same node? There may be other ways to achieve your goal. I want different IPs for similar microservices with different parameters, so replicas won’t do. The question is interesting regardless Each container gets it's own private internal IP by default, even when on the same host. And if you publish with ingress, a port will be opened on every host of the network. The answer to the question asked is "no" so I'm trying to see if there's a way to solve the underlying problem. Thanks for the input! If it’s a no, it’s a useful answer regardless

Initializing...