In front of our experimental environment there is only one Docker host, and all the containers are running on this host. However, in a real environment there will be multiple hosts, where containers are started, run, stopped, and destroyed, and related containers communicate with each other over the network, regardless of whether they are located in the same host.
How do we manage this multi-host environment effectively?
The first problem we faced was installing and configuring Docker for all hosts.
In front of us, we manually installed the first Docker host, including the following steps:
Install the HTTPS CA certificate
Add GPG Key
Add Docker apt Source
Installing Docker
Visible step is still quite a lot of, for multi-host environment manual way inefficient and not easy to ensure consistency, for this problem, Docker solution is the Docker machine.
Docker machine allows you to install and configure Docker host in batches, which can be local virtual machines, physical machines, or cloud hosts in a public cloud.
Docker machine supports installing and configuring Docker host in different environments, including:
General Linux Operating System
Virtualization platform-VirtualBox, VMWare, Hyper-V
OpenStack
Public cloud-Amazon Web Services, Microsoft Azure, Google Compute Engine, Digital Ocean, and more
Docker Machine has a unified name for these environments: provider. For a particular provider,docker machine, install and configure the Docker host with the appropriate driver, as shown in:
Here we study Docker machine through experiments.
Experimental environment Description
There are three host hosts running Ubuntu in the lab environment.
We will install Docker machine on the 192.168.56.101 and then deploy Docker on the other two hosts through the Docker-machine command.
Installing Docker Machine
Official installation documentation at https://docs.docker.com/machine/install-machine/
The installation method is simple and executes the following command:
curl-l https://github.com/docker/machine/releases/download/v0.9.0/docker-machine-' uname-s '-' uname-m ' >/ Tmp/docker-machine &&
chmod +x/tmp/docker-machine &&
sudo cp/tmp/docker-machine/usr/local/bin/docker-machine
The downloaded execution file is put into/usr/local/bin, and the docker-mahine version
Validation command is available:
> Note: When you see this article, the Docker machine should have an updated version, which can be installed by reference to the official documentation.
via tab
  key completion docker-mahine
  's subcommands and parameters. The installation method is downloaded from Https://github.com/docker/machine/tree/master/contrib/completion/bash completion script:
place it in   /ETC/BASH_COMPLETION.D
  directory. Then add the following code to $HOME/.BASHRC
:
ps1= ' [\[email protected]\h \w$ (__docker_machine_ps1)]\$ '
The effect is to set the command-line prompt for docker-machine, but wait until the other two hosts are deployed to see the effect.
The Docker machine is ready and the current environment is as follows:
In the next section we learn how to create machine.
Installing Docker machine-5 minutes a day to play Docker container technology (45)