How to install docker-machine on Centos/Linux machine?

In this article we will explain how to install docker-machine on Centos/Linux machine

docker-machine is a command-line tool used to install docker engine on Virtual Machines at  your local network or any cloud provider and manage docker containers on those.
With “docker-machine” , commands, you can start, inspect, stop, and restart a managed host, upgrade the Docker client and daemon. Also you can have docker client talk to the docker engine installed on remote managed machine.

How to install docker-machine on Centos/Linux ?

On a Linux/Centos machine, run the following commands to install docker-machine

1 2 3 4 5 6 7 8   ### Download the suitable version of the “docker-machine” from github and save /tmp/ curl L https://github.com/docker/machine/releases/download/v0.10.0/docker-machine-uname -suname -m > /tmp/docker-machine && ## Make it executable chmod +x /tmp/dockermachine ## Copy it to any of the folders which are listed in PATH variable sudo cp /tmp/dockermachine /usr/local/bin/dockermachine  

now you can use “docker-machine”

1. Check version

1 2 3 4 5   [root@test.test.com ~]# docker-machine -v dockermachine version 0.10.0, build 76ed2a6 [root@test.test.com ~]#  

2. Create first virtual Machine

We will use virtualbox driver this time to create new vm. Make sure you have virtualbox installed on this machine

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30   [root@test.test.com yum.repos.d]# docker-machine create –driver virtualbox default Creating CA: /root/.docker/machine/certs/ca.pem Creating client certificate: /root/.docker/machine/certs/cert.pem Running precreate checks... (default) Image cache directory does not exist, creating it at /root/.docker/machine/cache... (default) No default Boot2Docker ISO found locally, downloading the latest release... (default) Latest release for github.com/boot2docker/boot2docker is v17.05.0ce (default) Downloading /root/.docker/machine/cache/boot2docker.iso from https://github.com/boot2docker/boot2docker/releases/download/v17.05.0-ce/boot2docker.iso… (default) 0%....10%....20%....30%....40%....50%....60%....70%....80%....90%....100% Creating machine... (default) Copying /root/.docker/machine/cache/boot2docker.iso to /root/.docker/machine/machines/default/boot2docker.iso... (default) Creating VirtualBox VM... (default) Creating SSH key... (default) Starting the VM... (default) Check network to recreate if needed... (default) Found a new hostonly adapter: “vboxnet0” (default) Waiting for an IP... Waiting for machine to be running, this may take a few minutes... Detecting operating system of created instance... Waiting for SSH to be available... Detecting the provisioner... Provisioning with boot2docker... Copying certs to the local machine directory... Copying certs to the remote machine... Setting Docker configuration on the remote daemon... Checking connection to Docker... Docker is up and running! To see how to connect your Docker Client to the Docker Engine running on this virtual machine, run: dockermachine env default  

3. List the VM created

1 2 3 4 5 6   root@test.test.com ~]# docker-machine ls NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS default virtualbox Running tcp://192.168.99.100:2376 v17.05.0-ce [root@test.test.com ~]#  

4. Now connect your environment to newly created VM

Use the following command 

1 2 3   eval “$(docker-machine env default)”  

Now we can run docker commands on the VM just like doing on local machines. Whatever command you run with “docker” will be executed on the new VM you created and not on your machine. 

 

Author: , 0000-00-00