DEV Community

Deepak Sabhrawal
Deepak Sabhrawal

Posted on • Edited on

create docker hosted nodes using docker-machine

docker-machine is a component of docker, used to create docker hosted virtual nodes using different drivers like GCP, AWS, Azure, or Virtualbox. Docker hosted nodes are the machines running docker daemon and used to run the docker containers. The Docker machine tool is useful when you want to create a docker cluster on any of the drivers mentioned above using docker swarm.

Today, we will learn to create a virtual machine using docker-machine

Step 1: Check the latest release version available here.
Step 2: Run below command to install docker-machine (change the latest version you find from step 1)

$base=https://github.com/docker/machine/releases/download/v0.16.2 &&
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
Enter fullscreen mode Exit fullscreen mode

Click here for installation on Windows or Mac.

Step 3: Check successful installation

$docker-machine ls
NAME   ACTIVE   DRIVER       STATE     URL     SWARM     DOCKER     ERRORS
Enter fullscreen mode Exit fullscreen mode

*Run last command chmod +x /usr/local/bin/docker-machine if you see any permission issue

Step 4: Install Virtualbox driver for local installation of virtual machines

$sudo apt update && apt upgrade && apt install virtualbox
Enter fullscreen mode Exit fullscreen mode

Step 5: Create virtual machine on Virtualbox with name dev

$docker-machine create --driver virtualbox dev
Enter fullscreen mode Exit fullscreen mode

Step 6: Now, the $docker-machine ls command should return with running machine

$docker-machine ls
NAME   ACTIVE   DRIVER       STATE     URL                       SWARM   DOCKER  ERRORS
dev    -        virtualbox   Running   tcp://192.168.99.100:2376           v19.03.5   
Enter fullscreen mode Exit fullscreen mode

You successfully installed docker hosted virtual machine using Virtualbox driver locally, this node can be used for docker swarm worker nodes.

Happy dockering! Keep Learning!

Top comments (0)