Docker Swarm set which service goes to which machine.
Is there any way to set which service or service replicas goes to which worker machine ?
DevOps Stack Exchange is a question and answer site for software engineers working on automated testing, continuous delivery, service integration and monitoring, and building SDLC infrastructure. It only takes a minute to sign up.Sign up to join this community
In the placement section of the compose file, you can specify constraints. I'd recommend using node labels so you can add more potential nodes (should an existing node fail) without redefining any deployments bound to a node, but you can also specify hostnames. The result looks like:
version: "3.9" services: db: image: postgres deploy: placement: constraints: - "node.hostname==dbhost"