Create & manage docker hosts with Docker Machine on VirtualBox

Docker Machine is a tool that let us install Docker Engine on virtual hosts on various platforms, on local environment as well on cloud. With Docker Machine, we can easily install docker hosts a Windows machine, a MAC machine or on cloud platform like AWS, AZURE etc.

As we know that Docker Engine runs natively on Linux machines, so its pretty easy to get Docker working on Linux machines but for other OS like MAC or Windows this was a problem. So Docker Machine was introduced, especially for older versions of MAC & Windows (there are new native Docker apps for latest OS). Not meant only for Windows or MAC, Docker machine also provides efficient way to provision multiple Docker hosts on local as well as cloud network.

To manage the docker hosts, we use  rather than using ‘docker’ command, which is used with docker engine. In this tutorial, we will discuss how we can create & manage docker hosts with Docker Machine on VirtualBox.

(Recommended Read: Step by Step guide for creating Docker Image)



1- We need to have VirtualBox installed on our machines. To install VirtualBox, kindly refer to the our detailed article on “Installing VirtualBox on CentOS & Ubuntu”.

2- We should also have docker installed on our system. To install Docker on your system, refer to the article “Create your first Docker Container

Installing Docker Machine

Before creating a Docker host on VirtualBox, we will install the Docker Machine on our system. To install Docker machine, we will download it’s binary file using the following command,

$ curl -L`uname -s`-`uname -m` >/tmp/docker-machine

Next provide execute permissions to folder,

$ chmod +x /tmp/docker-machine

and lastly copy the downloaded folder to /usr/local/bin/.

$ cp /tmp/docker-machine /usr/local/bin/docker-machine

Docker machine has now been installed, we can test if the command is working or not by checking its version,

$ docker-machine -version

manage docker hosts with docker machine

Creating a Docker Host

Now that we have docker machine installed on our system, we will use it to create a docker host on virtualbox. Execute the following command on your terminal to create a docker host for virtualbox,

$ docker-machine create –driver virtualbox docker-local

Process will take some time.

manage docker hosts with docker machine

Once installed, open virtualbox & we can also see the Docker host installed there,

manage docker hosts with docker machine

Now to connect to Docker Host & to get all information regarding the host, run

$ docker-machine env docker-local

& you will get the following output on your terminal,

manage docker hosts with docker machine

Next, execute the following command to configure the shell,

$ eval $(docker-machine env docker-local)

Now all the docker commands that we run on our machine will actually be executed on VM machine & not on local machine.
To connect to the ssh session of docker host (docker-local), execute the following command,

$ docker-machine ssh docker.local

manage docker hosts with docker machine

Our VirtualBox Docker Host is now ready & we can manage docker hosts with docker machine command.


Docker-machine commands

Now let’s discuss some useful docker commands,

List all docker machine hosts-                    docker-machine ls
Show the host status –                                 docker-machine status docker-local
Get url for the host –                                    docker-machine url docker-local
Start a host –                                                 docker-machine start docker-local
Stop a host-                                                   docker-machine stop docker-local
Restart a host-                                               docker-machine restart docker-local
Remove a host-                                             docker-machine rm docker-local
Detailed information about the host-          docker-machine inspect docker-local


These were only some of the important commands used with docker-machine. For complete list of commands, run

$ docker-machine –help

With this we complete our tutorial on how to create & manage Docker hosts with Docker Machine, please feel free to send in your queries & questions using the comment box below.


If you think we have helped you or just want to support us, please consider these :-

Connect to us: Facebook | Twitter | Google Plus

Donate us some of you hard earned money:

Linux TechLab is thankful for your continued support.


Passionate about Linux & open source. Loves to learn, read & write about Linux as well as new technologies.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *