Reputation: 15424
Let's say I have 3 separate machines:
redis$ docker-machine ls
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
redis-master * virtualbox Running tcp://192.168.99.101:2376 v1.10.1
redis-slave1 - virtualbox Running tcp://192.168.99.102:2376 v1.10.1
redis-slave2 - virtualbox Running tcp://192.168.99.103:2376 v1.10.1
I want to use docker-compose
to easily deploy master or slave to one of those three machines. For now my docker-compose.yml file looks like this:
redis:
image: redis:3.0
sentinel:
image: redis:3.0
command: "redis-server --sentinel"
How should I modify my docker-compose.yml file to make it work? At the end I would like to be able to start containers like this for example:
$ NODE_ROLE=master docker-compose up # on master machine
$ NODE_ROLE=slave MASTER_ADDRESS=192.168.99.101:2376 docker-compose up # on slave machine 1
$ NODE_ROLE=slave MASTER_ADDRESS=192.168.99.101:2376 docker-compose up # on slave machine 2
I saw some repositories with redis + docker + sentinel setup, but all of them run all instances on same docker host...
Upvotes: 1
Views: 1020
Reputation: 28040
I think you should look into using https://github.com/docker/swarm
Swarm allows you to treat multiple machines as a single docker engine. You can then let the swarm scheduler decide where to run the container, or use a constraint to put the container on a specific node.
Upvotes: 2