Docker Machine
brief introduction
Docker Machine is a tool that allows you to install docker on a virtual host, and you can use the Docker Machine command to manage the host.
Docker Machine can also centrally manage all docker hosts, such as quickly installing docker on 100 servers.
The virtual hosts managed by Docker Machine can be on-board or cloud providers, such as Alibaba cloud, Tencent cloud, AWS, or DigitalOcean.
Using the Docker machine command, you can start, check, stop and restart the managed host, upgrade the Docker client and daemon, and configure the Docker client to communicate with your host.
install
You need to install Docker before installing Docker Machine.
Docker Machine can be installed and used on a variety of platforms, including Linux, MacOS and windows.
Linux Installation command
$ base=https://github.com/docker/machine/releases/download/v0.16.0 && curl -L $base/docker-machine-$(uname -s)-$(uname -m) >/tmp/docker-machine && sudo mv /tmp/docker-machine /usr/local/bin/docker-machine && chmod +x /usr/local/bin/docker-machine
macOS installation command
$ base=https://github.com/docker/machine/releases/download/v0.16.0 && curl -L $base/docker-machine-$(uname -s)-$(uname -m) >/usr/local/bin/docker-machine && chmod +x /usr/local/bin/docker-machine
Windows installation command
If you are a Windows platform, you can use Git BASH , and enter the following command:
$ base=https://github.com/docker/machine/releases/download/v0.16.0 && mkdir -p "$HOME/bin" && curl -L $base/docker-machine-Windows-x86_64.exe > "$HOME/bin/docker-machine.exe" && chmod +x "$HOME/bin/docker-machine.exe"
Check whether the installation is successful:
$ docker-machine version docker-machine version 0.16.0, build 9371605
use
This chapter introduces the use of docker machine through virtual box. The operations of other cloud service providers are basically the same. For details, please refer to the guidance documents of each service provider.
1. List available machines
You can see that there is only the default virtual machine here at present.
$ docker-machine ls
2. Create machine
Create a machine called test.
$ docker-machine create --driver virtualbox test
- --Driver: Specifies the type of driver used to create the machine. Here is the virtualbox.
3. View the ip address of the machine
$ docker-machine ip test
4. Stop the machine
$ docker-machine stop test
5. Start the machine
$ docker-machine start test
6. Enter the machine
$ docker-machine ssh test
Description of docker machine command parameters
-
Docker machine active: view the docker host in the current active state.
$ docker-machine ls NAME ACTIVE DRIVER STATE URL dev - virtualbox Running tcp://192.168.99.103:2376 staging * digitalocean Running tcp://203.0.113.81:2376 $ echo $DOCKER_HOST tcp://203.0.113.81:2376 $ docker-machine active staging
- config: view the connection information of Docker host in the current active state.
- create: creates a Docker host
- env: displays the environment variables required to connect to a host
- inspect: output the detailed information of the specified Docker in json format
- ip: get the address of the specified Docker host
- Kill: directly kill the specified Docker host
- ls: list all management hosts
- provision: reconfigure the specified host
- Regenerate certs: regenerate TLS information for a host
- Restart: restart the specified host
- rm: when a Docker host is deleted, the corresponding virtual machine will also be deleted
- SSH: connect to the host through SSH and execute the command
- scp: remote replication of data between Docker hosts and between Docker hosts and local hosts through scp
- Mount: use SSHFS to mount or unmount directories from the computer
- Start: start a specified Docker host. If the object is a virtual machine, the virtual machine will be started
- Status: get the status of the specified Docker host (including: Running, Paused, Saved, Stopped, Stopping, Starting, error, etc.)
- Stop: stop a specified Docker host
- upgrade: update the Docker version of a specified host to the latest version
- URL: get the listening URL of the specified Docker host
- Version: displays the Docker Machine version or host Docker version
- Help: displays help information