Container Clustering Using Docker Swarm & Docker Machine
Docker Swarm is native clustering for Docker. It turns a pool of Docker hosts into a single, virtual Docker host. 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.
Container Clustering Using Docker Swarm & Docker Machine:
Docker Engine
When people say “Docker” they typically mean Docker Engine, the client-server application made up of the Docker daemon, a REST API that specifies interfaces for interacting with the daemon, and a command line interface (CLI) client that talks to the daemon (through the REST API wrapper).
Docker Engine accepts docker commands from the CLI, such as docker run <image>
, docker ps to list running containers, docker images to list images, and so on.
Engine is the core of Docker and nothing else will run without it. Ref: docker.
Docker Architecture
Docker uses a client-server architecture. The Docker client talks to the Docker daemon, which does the heavy lifting of building, running, and distributing your Docker containers.
Both the Docker client and the daemon can run on the same system, or you can connect a Docker client to a remote Docker daemon.
The Docker client and daemon communicate via sockets or through a RESTful API.
Docker daemon
The Docker daemon runs on a host machine. The user does not directly interact with the daemon, but instead through the Docker client.
Docker client
The Docker client, in the form of the docker binary, is the primary user interface to Docker.
It accepts commands from the user and communicates back and forth with a Docker daemon.
Docker Machine
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”.
Using docker-machine commands, you can start, inspect, stop, and restart a managed host, upgrade the Docker client and daemon, and configure a Docker client to talk to your host.
Point the Machine CLI at a running, managed host, and you can run docker commands directly on that host. For example, run docker-machine env default to point to a host called default, follow on-screen instructions to complete env setup, and run docker ps, docker run hello-world, and so forth.
Docker Swarm
Docker Swarm is native clustering for Docker.
It turns a pool of Docker hosts into a single, virtual Docker host.
Because Docker Swarm serves the standard Docker API, any tool that already communicates with a Docker daemon can use Swarm to transparently scale to multiple hosts.
Swarm Discovery Token
In this case, we are using the discovery backend hosted on Docker Hub to create a unique discovery token for the cluster. This discovery backend is only for low-volume development and testing purposes.
The discovery backend maintains an up-to-date list of cluster members and shares that list with the Swarm manager. The Swarm manager uses this list to assign tasks to the nodes.