LinuxCommandLibrary

docker-machine

Manage Docker hosts (e.g., VMs)

TLDR

List currently running Docker machines

$ docker-machine ls
copy

Create a new Docker machine with specific name
$ docker-machine create [name]
copy

Get the status of a machine
$ docker-machine status [name]
copy

Start a machine
$ docker-machine start [name]
copy

Stop a machine
$ docker-machine stop [name]
copy

Inspect information about a machine
$ docker-machine inspect [name]
copy

SYNOPSIS

docker-machine [GLOBAL OPTIONS] COMMAND [ARG...]

PARAMETERS

GLOBAL OPTIONS
    Options that affect the overall behavior of the docker-machine command.

--debug, -D
    Enable debug mode, printing verbose output for troubleshooting.

--storage-path=<path>
    Specify the path where machine configurations and certificates are stored. Defaults to ~/.docker/machine.

--tls-skip-verify
    Skip TLS verification for the Docker daemon connection. Use with caution, as it bypasses security checks.

--github-api-token=<token>
    A GitHub API token used by certain drivers (e.g., to check for updates).

COMMANDS
    Subcommands perform specific actions on Docker machines.

create <machine-name>
    Creates a Docker host. Requires specifying a driver using --driver (e.g., virtualbox, amazonec2, google) and driver-specific options (e.g., --virtualbox-memory, --amazonec2-instance-type).

ls
    Lists all managed Docker machines, showing their state, IP address, and Docker version. Accepts --quiet for names only or --filter for conditional listing.

start <machine-name>
    Starts one or more stopped Docker machines.

stop <machine-name>
    Stops one or more running Docker machines gracefully.

rm <machine-name> [flags]
    Removes one or more Docker machines and their associated resources. Use -f or --force for forced removal without confirmation.

ssh <machine-name> [command]
    Connects to a Docker machine via SSH. An optional command can be executed directly on the machine without an interactive session.

ip <machine-name>
    Gets the IP address of a Docker machine.

env <machine-name>
    Prints the commands required to set up the shell environment to interact with the Docker daemon on the specified machine. Typically used with eval $(docker-machine env <machine-name>).

inspect <machine-name>
    Displays detailed information about a Docker machine in JSON format.

upgrade <machine-name>
    Upgrades the Docker client and daemon on a machine to the latest stable version.

config <machine-name>
    Prints the connection configuration (e.g., DOCKER_HOST, DOCKER_TLS_VERIFY) for a machine.

DESCRIPTION

docker-machine is a command-line tool designed to provision and manage Docker hosts across various platforms. It can create Docker Engine-ready virtual machines on your local computer using hypervisors like VirtualBox, or on numerous cloud providers such as AWS, Azure, Google Cloud, and DigitalOcean. Once a machine is created, docker-machine provides commands to start, stop, restart, remove, and upgrade it. It also facilitates connecting to these machines via SSH, retrieving their IP addresses, and configuring your local Docker client to communicate with the Docker daemon running on the provisioned host.

This tool was particularly significant in enabling Docker's functionality on non-Linux operating systems (like macOS or Windows) before the advent of Docker Desktop, as it abstracted away the underlying VM management. While still functional, its primary role in local development has largely been superseded by more integrated solutions like Docker Desktop, and in production environments by cloud-native tools and container orchestration platforms.

CAVEATS

docker-machine is considered largely superseded for local Docker development by Docker Desktop (for Windows/macOS/Linux) which provides a more integrated and user-friendly experience.

While still functional for provisioning remote Docker hosts, cloud providers' native CLI tools (e.g., aws cli, gcloud cli, az cli) and infrastructure-as-code solutions (e.g., Terraform) are often preferred for managing cloud-based VMs and their configurations due to greater flexibility and integration with broader cloud ecosystems. Its development activity has significantly slowed, and new features or drivers are rarely added.

CURRENT RELEVANCE AND ALTERNATIVES

While docker-machine remains a powerful tool for provisioning Docker hosts, its direct relevance for day-to-day local Docker development has diminished. For macOS and Windows, Docker Desktop is the recommended and much simpler solution, as it bundles a lightweight VM and manages the Docker Engine transparently.

For cloud environments, direct interaction with cloud provider CLIs or robust infrastructure-as-code tools like Terraform are often preferred for their flexibility, scalability, and integration with broader cloud ecosystems. docker-machine might still be valuable for creating temporary, isolated Docker testing environments, for highly customized remote host provisioning where specific drivers are ideal, or for maintaining specific legacy setups that rely on its unique machine provisioning capabilities.

HISTORY

docker-machine was introduced by Docker in 2015 as a key component of its strategy to bring Docker to non-Linux operating systems like macOS and Windows. Before its release, running Docker on these platforms typically required manually setting up a VirtualBox VM and configuring Docker.

docker-machine automated this process, providing a consistent command-line interface to provision and manage these underlying Linux VMs that hosted the Docker Engine. Its importance in local development significantly decreased with the release of Docker for Mac and Docker for Windows (now collectively Docker Desktop) in 2016, which provided a more seamless and native user experience without the need for explicit VM management. Today, it primarily serves niche use cases for provisioning isolated Docker hosts or for managing specific legacy systems.

SEE ALSO

docker(1), docker-compose(1), kubectl(1), aws(1), gcloud(1), az(1), VirtualBox(1)

Copied to clipboard