Easy Tutorial
❮ Docker Install Apache Docker Rmi Command ❯

Docker Machine

Introduction

Docker Machine is a tool that allows you to install Docker on virtual hosts and manage them with the docker-machine command.

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 local or cloud providers like Alibaba Cloud, Tencent Cloud, AWS, or DigitalOcean.

Using the docker-machine command, you can start, inspect, stop, and restart managed hosts, upgrade the Docker client and daemon, and configure the Docker client to communicate with your hosts.


Installation

Before installing Docker Machine, you need to install Docker.

Docker Machine can be installed on various 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 on Windows, 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"

To check if the installation was successful:

$ docker-machine version
docker-machine version 0.16.0, build 9371605

Note: The installation instructions can also be found in the release notes for each version: https://github.com/docker/machine/releases


Usage

This chapter introduces the usage of docker-machine through virtualbox. The operations for other cloud service providers are generally consistent. Refer to the specific documentation of each service provider for details.

1. List Available Machines

You can see that only the default virtual machine is available here.

$ docker-machine ls

2. Create a Machine

Create a machine named "test".

$ docker-machine create --driver virtualbox test

--driver: Specifies the driver type used to create the machine, in this case, virtualbox.

3. View Machine IP

$ docker-machine ip test

4. Stop a Machine

$ docker-machine stop test

5. Start a Machine

$ docker-machine start test

6. Access a Machine

$ docker-machine ssh test

docker-machine Command Parameters

❮ Docker Install Apache Docker Rmi Command ❯