Search code examples
dockerdocker-composedocker-swarm

Docker compose on docker swarm cluster separate containers on separate nodes


Running docker compose which composes several containers for database application and logs on docker swarm cluster makes all of them run on each node of the docker swarm. But what is needed is to spread it for instance I have 4 nodes and on 3 of them needed to be run replica set and on fourth application. How could I user docker compose and swarm for that? Or may be some other tools are needed.


Solution

  • To run things on separate nodes you need to use the new docker networking which is in the docker 1.9, swarm 1.0 and compose 1.5 releases.

    If you're using the latest version of each, you can set node labels on each node and use swarm constraints to place specific services on specific nodes.

    With compose 1.5.0 you'll need to use the --x-networking option to enable multi-host networking.