Before we did the experiment is on a host, in fact, in the real environment there are multiple hosts, containers on these hosts to start, run, stop and destroy, related containers will communicate with each other over the network, whether they are running on the same host.
For this kind of song Multi-host environment, how should we manage it efficiently?
The first problem is: Install and configure Docker for all hosts
Previously, we installed a Docker host manually:
1. Install the HTTPS CA certificate
2. Add GPG Key
3. Add Docker apt Source
4. Installing Docker
for multi-master environments where manual methods are inefficient and not easy to guarantee consistency, the solution for Docker is the Docker machine
Docker machine allows you to install and configure Docker host in bulk, which can be a local VM, a physical machine, or a cloud host in a public cloud
Docker machine supports the installation of Docker host in different environments, including:
1. Regular Linux operating system;
2. Virtualization Platform-virtualbox,vmware,hyper-v
3.Openstack
4. Public cloud-amazon Web services,microsoft azure,google Compute engine,digital Ocean etc.
Docker Machine has a unified name for these environments: provider
Configure the Docker host with the appropriate driver installation for a specific provider,docker machine
Installing Docker Machine
Lab Environment: Host name IP operating system
Docker 192.168.7.222 Centos7
Docker1 192.168.7.235 centos7
Docker2 192.168.7.231 centos7
I'll install Docker machine on 192.168.7.222 Docker and then deploy Docker on the other two hosts with the Docker machine command
To install Docker machine, refer to the official documentation: https://docs.docker.com/machine/install-machine/#install-machine-directly
Executes the docker-machine version Validation command is available
Note: It is recommended to build according to official documents
Install bash Completion script so that bash can fill commands and Parameters with tab:
Download Completion Script:docker-machine-prompt.bash Docker-machine-wrapper.bash Docker-machine.bash place it in/etc/bash_compl Under the ETION.D directory
The command is: Scripts= (Docker-machine-prompt.bash docker-machine-wrapper.bash docker-machine.bash ); For i in "${scripts[@]}"; Do sudo wget https://raw.githubusercontent.com/docker/machine/v0.13.0/contrib/completion/bash/${I }-P/ETC/BASH_COMPLETION.D; Done
Then add the following code to the ~/.BASHRC
Ps1= ' [\[email protected]\h \w$ (__docker_machine_ps1)]\$ '
If a situation arises:
Change ~/.BASHRC and add the following three lines in BASHRC:
Source/etc/bash_completion.d/docker-machine-wrapper.bash
Source/etc/bash_completion.d/docker-machine-prompt.bash
Source/etc/bash_completion.d/docker-machine.bash
Re-source under BASHRC
Source/root/.bashrc
The installation is complete at this location Docker-machine!
How to uninstall Docker-machine, you can refer to the official documentation!
Installing Docker under CENTOS7 (14 installing Docker machine)