Reputation: 23
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.
Upvotes: 1
Views: 717
Reputation: 25802
Nowadays the right way to create a Docker multi-host network with docker-swarm
is through the overlay
network driver.
Basically you use docker-swarm
to create a cluster with multiple nodes and configure the swarm cluster to support multi-host networking with the overlay
driver.
Once your swarm cluster
is setup with the overlay driver
, you or docker-compose
will be able to spread your containers through multiple nodes.
Unfortunately, overlay networks require some pre-existing conditions before you can create one, see more details here:
Get started with multi-host networking
Tested with:
Note: The composer flag --x-networking
has been deprecated and this flag is not longer present on version 1.6 or higher.
Upvotes: 0
Reputation: 28160
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.
Upvotes: 2