Docker Machine is a command-line tool that creates virtual machines, installs Docker Engine on them, and points your local docker client at them. This page explains the docker-machine commands listed above, fixes a few problems in that list, and walks through a full lifecycle with the VirtualBox driver. Docker Machine has been deprecated and archived by Docker, so the page also covers what to use instead.
> docker-machine ls
> docker-machine create --driver virtualbox server1
> docker-machine create --driver virtualbox server1
> docker-machine ip default
> docker-machine status default
> docker-machine env default
> docker-machine
> docker-machine stop default
> docker-machine start default
> docker-machine env server1
> eval $("C:\Program Files\Docker Toolbox\docker-machine.exe" env server1)Code language: JavaScript (javascript)
Read this first: Docker Machine is deprecated
Docker Machine and Docker Toolbox are no longer maintained. Docker archived the docker/machine repository, and the last official release was v0.16.2. The commands on this page still work where the tool is installed, so the information is useful for maintaining older environments, following legacy course material, or understanding how remote Docker hosts work. Do not use Docker Machine for new projects.
| Need | Current replacement |
|---|---|
| Run Docker on a Windows or macOS laptop | Docker Desktop, Rancher Desktop or Colima (macOS/Linux) |
| Point the local CLI at a remote Docker host | docker context with an SSH endpoint |
| Create disposable Linux VMs for labs | Vagrant, Multipass, or cloud VMs provisioned with Terraform |
| Multi-node clusters | Docker Swarm (docker swarm init) or Kubernetes |
Prerequisites
- The Docker CLI (
docker) installed on your workstation. - VirtualBox installed. On Windows, Hyper-V and features that depend on it (WSL 2, Docker Desktop) can conflict with VirtualBox, depending on your VirtualBox version.
- The
docker-machinebinary. Docker Toolbox for Windows bundled it atC:\Program Files\Docker Toolbox\docker-machine.exe. On Linux or macOS you can install the last release binary as shown below. - An Intel/AMD (x86_64) host. The VirtualBox driver and the boot2docker ISO do not work on Apple Silicon Macs.
# Linux / macOS (x86_64): install the final Docker Machine release
base=https://github.com/docker/machine/releases/download/v0.16.2
curl -L $base/docker-machine-$(uname -s)-$(uname -m) -o /tmp/docker-machine
sudo install /tmp/docker-machine /usr/local/bin/docker-machine
docker-machine versionCode language: PHP (php)
What each command in the example above does
| Command | Purpose |
|---|---|
docker-machine ls | Lists all machines with their driver, state, Docker URL and Docker version. |
docker-machine create --driver virtualbox server1 | Creates a VirtualBox VM named server1 from the boot2docker ISO, installs Docker, and generates TLS certificates. |
docker-machine ip default | Prints the IP address of the machine named default. |
docker-machine status default | Prints Running, Stopped, Saved or Error. |
docker-machine env default | Prints the environment variables that point the Docker CLI at that machine. It does not change anything by itself. |
docker-machine | With no subcommand, prints the help and the list of subcommands. |
docker-machine stop default / start default | Shuts down or boots the VM. The IP address can change after a restart. |
eval $(... env server1) | Runs the printed export lines in the current shell, so later docker commands talk to server1. |
Note: The machine default only exists if you created it yourself or ran the Docker Quickstart Terminal from Docker Toolbox, which creates it automatically. If you only ran the create command above, use server1 instead.
Corrected command list
The example above has a duplicated create line (the second run fails with Docker machine "server1" already exists), mixes the machine names default and server1, and includes > prompt characters that break copy and paste. Here is a consistent version that uses one machine:
docker-machine ls
docker-machine create --driver virtualbox server1
docker-machine ip server1
docker-machine status server1
docker-machine env server1
eval $(docker-machine env server1) # bash/zsh, including Git Bash
docker-machine stop server1
docker-machine start server1
docker-machine regenerate-certs -f server1 # needed if the IP changed after startCode language: PHP (php)
The final line in the original, eval $("C:\Program Files\Docker Toolbox\docker-machine.exe" env server1), only works in a bash shell on Windows such as Git Bash or the Docker Quickstart Terminal. It fails in Command Prompt and PowerShell, which need different syntax:
# PowerShell
& "C:\Program Files\Docker Toolbox\docker-machine.exe" env --shell powershell server1 | Invoke-Expression
# Command Prompt (cmd.exe)
@FOR /f "tokens=*" %i IN ('docker-machine env --shell cmd server1') DO @%iCode language: PHP (php)
End-to-end walkthrough with expected output
- Create the machine:
docker-machine create --driver virtualbox --virtualbox-memory 2048 --virtualbox-cpu-count 2 server1. The first run downloads the boot2docker ISO, so it takes a few minutes. - Check it:
docker-machine lsshould showserver1with stateRunningand a URL liketcp://192.168.99.100:2376. - Look at the environment:
docker-machine env server1. - Apply it:
eval $(docker-machine env server1).docker-machine lsnow shows*in the ACTIVE column forserver1. - Run a container on the VM:
docker run -d -p 8080:80 nginx, then openhttp://$(docker-machine ip server1):8080. The port is published on the VM's IP, not onlocalhost. - Switch back to your local Docker engine:
eval $(docker-machine env -u).
$ docker-machine ls
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
server1 - virtualbox Running tcp://192.168.99.100:2376 v19.03.12
$ docker-machine env server1
export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://192.168.99.100:2376"
export DOCKER_CERT_PATH="/home/user/.docker/machine/machines/server1"
export DOCKER_MACHINE_NAME="server1"
# Run this command to configure your shell:
# eval $(docker-machine env server1)Code language: PHP (php)
Your IP address, paths and Docker version may be different. Once the variables are set, every docker command in that shell (for example those in docker run with examples) runs against the VM.
Other useful commands
| Command | What it does |
|---|---|
docker-machine ssh server1 | Opens a shell on the VM. Add a command to run it once, e.g. docker-machine ssh server1 "df -h". |
docker-machine scp file.txt server1:/home/docker/ | Copies files between the host and the machine. |
docker-machine active | Shows which machine the current shell points at. |
docker-machine inspect server1 | Prints the machine's full JSON configuration. |
docker-machine url server1 | Prints the Docker daemon URL. |
docker-machine restart server1 | Restarts the VM. |
docker-machine rm -y server1 | Deletes the VM and its certificates. Containers and volumes on it are lost. |
docker-machine create --driver generic --generic-ip-address 10.0.0.5 --generic-ssh-user ubuntu --generic-ssh-key ~/.ssh/id_rsa server2 | Installs Docker on an existing Linux host over SSH instead of creating a VM. |
Common errors and fixes
| Error or symptom | Cause | Fix |
|---|---|---|
VBoxManage: error: ... E_ACCESSDENIED when creating the host-only adapter | Newer VirtualBox releases on Linux and macOS only allow host-only networks in 192.168.56.0/21 by default. Docker Machine uses 192.168.99.1/24. | Add --virtualbox-hostonly-cidr "192.168.56.1/24" to create, or allow the range in /etc/vbox/networks.conf (e.g. * 192.168.99.0/24). |
This computer doesn't have VT-X/AMD-v enabled | Hardware virtualisation is off in the BIOS/UEFI, or Hyper-V is holding it on Windows. | Enable VT-x/AMD-V in firmware. On Windows, disable Hyper-V or use Docker Desktop instead. |
x509: certificate is valid for 192.168.99.100, not 192.168.99.101 | The VM got a new IP after a restart. | docker-machine regenerate-certs -f server1, then re-run eval $(docker-machine env server1). |
Cannot connect to the Docker daemon after opening a new terminal | Environment variables apply only to the shell where you ran eval. | Run the eval command again in each new shell. |
Docker machine "server1" already exists | create was run twice with the same name. | Use docker-machine start server1, or remove it with docker-machine rm server1 first. |
Security notes and the modern way to reach a remote engine
- Docker Machine secures the daemon on port 2376 with TLS client certificates stored under
~/.docker/machine/machines/<name>. Anyone who has those files has root-equivalent access to the host, so protect them like SSH private keys. - Do not open port 2375 (the unencrypted Docker API) on any host.
- boot2docker images are no longer updated, so they do not receive security fixes. Do not use them for anything exposed to a network.
To control a remote Docker host today, use Docker contexts over SSH. No extra tool or certificate management is needed:
docker context create server1 --docker "host=ssh://ubuntu@10.0.0.5"
docker context use server1
docker ps # runs against the remote engine
docker context use defaultCode language: PHP (php)
Frequently asked questions
Is Docker Machine still supported?
No. Docker deprecated Docker Machine and Docker Toolbox and archived the project. The last release is v0.16.2. Use Docker Desktop, Colima or Rancher Desktop for local engines and docker context for remote ones.
What replaced docker-machine env?
docker context create and docker context use. They switch the CLI between engines without setting environment variables, and the setting persists across new terminals.
Why can't I reach my container on localhost when using Docker Machine?
Containers run inside the VM, so published ports are bound to the VM's IP address. Use docker-machine ip <name> to get the address, then browse to that IP and port.
How do I stop my shell from using the Docker Machine VM?
Run eval $(docker-machine env -u) in bash or zsh. It unsets DOCKER_HOST, DOCKER_TLS_VERIFY, DOCKER_CERT_PATH and DOCKER_MACHINE_NAME, so the CLI goes back to the local engine.
Does Docker Machine work on Apple Silicon Macs?
Not with the VirtualBox driver. The boot2docker ISO is x86_64-only. Use Docker Desktop or Colima on Apple Silicon.
Related tutorials
- What is Docker and use cases of Docker?
- Docker commands Guide โ docker run with examples
- Docker Lab, Excercise & Assignment โ 2
- More Docker tutorials
I’m Rajesh Kumar, a DevOps, SRE, DevSecOps, Cloud, and Platform Engineering expert passionate about sharing practical knowledge, real-world experiences, and industry best practices. I have worked at Cotocus and regularly write about technology, travel, investing, health, product reviews, and digital marketing through my various platforms.
I publish technical articles at DevOps School, travel stories at Holiday Landmark, stock market insights at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at TrueReviewNow, and SEO and digital marketing strategies at Wizbrand.
Find Trusted Cardiac Hospitals
Compare heart hospitals by city and services โ all in one place.
Explore Hospitals