Docker-compose: deploying service in multiple hosts

I have a docker-compose file that deploys 8 different docker services in the same host. Is it possible to deploy it in different hosts?, I would like to deploy some service in one hosts and another ones in other host remotelly. Would I need to use docker-swarm? or is an easier way to do?

I have read that it could be done using DOCKER_HOST, but if I configure /etc/default/docker with this variable, all the services would be run on the remote host, and what I need is some services in one remote host, and other services in other remote host.

  • install and Run Kurento Media server in Cent OS 6.6 using Docker
  • Debate on using heavy duty java rest service on docker, should we switch?
  • Generating new (not renewed) SSL Certificates with “letsencrypt certonly” in non-interactive mode
  • What is the benefit of convoy-glusterfs over pure glusterfs
  • Running svn update script on docker container start
  • Docker - denied: Your Authorization Token has expired
  • How do I append to PATH environment variable when running a Docker container?
  • Way to increase Boot2Docker volume size or alternative to install docker images locally
  • HBase 1.2.1 standalone in Docker unable to connect
  • Share Existing Host Directory with Docker Container?
  • Can you run GUI apps in a docker container?
  • docker-compose conflicts with Dokerfile entry-point script
  • 2 Solutions collect form web for “Docker-compose: deploying service in multiple hosts”

    For a single docker-compose.yml to deploy to multiple hosts, you need to use the standalone swarm (not the newer swarm mode, yet, this is rapidly changing). Spin up a swarm manager that has each host defined as members of its swarm, and then you can use constraints inside your docker-compose.yml to define which services run on which hosts.

    You can also split up your docker-compose.yml into several files, one for each host, and then run multiple docker-compose up commands, with a different DOCKER_HOST value defined for each.

    In both cases, you’ll need to configure your docker installs to listen on the network, which should be done by configuring TLS on those sockets. This documentation describes what you need to do for that.

    You can use docker compose version 3 which provides ability to do multi host deployment without using multiple compose files. All you need is to define labels for each node in the cluster and use the label name for placement constraint.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.