What is the difference between using Docker Machine with Swarm and using Swarm through the Docker daemon?

3.5k views Asked by At

What exactly is the difference between having multiple docker machines in a swarm (a manager and many nodes) and having multiple replicas of a docker service in a swarm?

2

There are 2 answers

4
Alexander George On BEST ANSWER

Well, since nobody answered this, I carried on reading more on the Internet trying to understand what's the difference between this two concepts. This is what I understand so far:

  • A Docker Machine is a very small virtual machine that runs an instance of the Docker Engine. This means we can run Docker containers inside it. It can be understood as a container of containers.
  • The Docker Engine has (since the 1.12 version) a module called Swarm Mode, which offers built-in support for connecting and orchestrating many machines (physical or virtual -- like Docker Machines) containing the Docker Engine. This basically builds a network of nodes that are directed by a manager -- a central node. At this point, an instance of a service could be replicated, and the manager would spread the replicas over the nodes efficiently.
  • Alternatively, Docker Machines can run Swarm containers (based on the Swarm image), which can be set up to behave in a similar way as in the previous case. Again, we can have a Docker Machine behaving as a manager and many others behaving as nodes, only this time the manager will not balance replicas of a service, but whole containers. When launching a new container, the manager will distribute it to a certain node. This is the standalone version of Swarm, and is only recommended when using a version of Docker previous to 1.12 -- otherwise the Swarm Mode is a better option.

I hope this helps.

0
user216 On

Docker Machine is a tool for provisioning and managing your Dockerized hosts (hosts with Docker Engine on them). Typically, you install Docker Machine on your local system. Docker Machine has its own command line client docker-machine and the Docker Engine client, docker. You can use Machine to install Docker Engine on one or more virtual systems. These virtual systems can be local (as when you use Machine to install and run Docker Engine in VirtualBox on Mac or Windows) or remote (as when you use Machine to provision Dockerized hosts on cloud providers). The Dockerized hosts themselves can be thought of, and are sometimes referred to as, managed “machines”.

https://docs.docker.com/machine/overview/#whats-the-difference-between-docker-engine-and-docker-machine

Docker Machine: Tool for provisioning and managing docker hosts (virtual hosts running docker engine). It automatically creates hosts, installs Docker Engine on them, then configures the docker clients. You can use Machine to create Docker hosts on your local machine using a virtualization software like VirtualBox or VMWare Fusion. Docker machine also supports various cloud providers like AWS, Azure, Digital Ocean, Google Compute Engine, OpenStack, RackSpace etc.

Docker Swarm: A swarm is a group of docker hosts linked together into a cluster. The swarm cluster consists of a swarm manager and a set of workers. You interact with the cluster by executing commands on the swarm manager. With swarm, you can deploy and scale your applications to multiple hosts. Swarm helps with managing, scaling, networking, service discovery, and load balancing between the nodes in the cluster.

https://www.callicoder.com/docker-machine-swarm-stack-golang-example/