Docker Machine is a tool that lets you install Docker Engine on virtual hosts, and manage the hosts with docker-machine commands. You can use Machine to create Docker hosts on your local Mac or Windows box, on your company network, in your data center, or on cloud providers like Azure, AWS, or Digital Ocean.
Using docker-machine commands, you can start, inspect, stop, and restart a managed host, upgrade the Docker client and daemon, and configure a Docker client to talk to your host.
Why should I use it?
Docker Machine enables you to provision multiple remote Docker hosts on various flavors of Linux.
Additionally, Machine allows you to run Docker on older Mac or Windows systems, as described in the previous topic.
[root@jenkins ~]# sudo curl -L https://github.com/docker/machine/releases/download/v0.12.2/docker-machine-`uname -s`-`uname -m` >/tmp/docker-machine &&
> chmod +x /tmp/docker-machine &&
> sudo cp /tmp/docker-machine /usr/local/bin/docker-machine
[root@jenkins ~]# docker-machine version
docker-machine version 0.12.2, build 9371605
Creating docker virtual machine
mohammedrafi@NOC-RAFI:~$ docker-machine create –driver virtualbox default
Creating CA: /home/mohammedrafi/.docker/machine/certs/ca.pem
Creating client certificate: /home/mohammedrafi/.docker/machine/certs/cert.pem
Running pre-create checks…
(default) You are using version 4.3.36_Ubuntur105129 of VirtualBox. If you encounter issues, you might want to upgrade to version 5 at https://www.virtualbox.org
(default) Image cache directory does not exist, creating it at /home/mohammedrafi/.docker/machine/cache…
(default) No default Boot2Docker ISO found locally, downloading the latest release…
(default) Latest release for github.com/boot2docker/boot2docker is v17.06.2-ce
(default) Downloading /home/mohammedrafi/.docker/machine/cache/boot2docker.iso from https://github.com/boot2docker/boot2docker/releases/download/v17.06.2-ce/boot2docker.iso…
mohammedrafi@NOC-RAFI:~$ sudo ufw disable
Firewall stopped and disabled on system startup
mohammedrafi@NOC-RAFI:~$ docker-machine create –driver virtualbox default
Running pre-create checks…
(default) You are using version 4.3.36_Ubuntur105129 of VirtualBox. If you encounter issues, you might want to upgrade to version 5 at https://www.virtualbox.org
(default) No default Boot2Docker ISO found locally, downloading the latest release…
(default) Latest release for github.com/boot2docker/boot2docker is v17.06.2-ce
(default) Downloading /home/mohammedrafi/.docker/machine/cache/boot2docker.iso from https://github.com/boot2docker/boot2docker/releases/download/v17.06.2-ce/boot2docker.iso…
(default) 0%….10%….20%….30%….40%….50%….60%….70%….80%….90%….100%
Creating machine…
(default) Copying /home/mohammedrafi/.docker/machine/cache/boot2docker.iso to /home/mohammedrafi/.docker/machine/machines/default/boot2docker.iso…
(default) Creating VirtualBox VM…
(default) Creating SSH key…
(default) Starting the VM…
(default) Check network to re-create if needed…
(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: docker-machine env default
mohammedrafi@NOC-RAFI:~$ docker-machine env default
export DOCKER_TLS_VERIFY=”1″
export DOCKER_HOST=”tcp://192.168.99.100:2376″
export DOCKER_CERT_PATH=”/home/mohammedrafi/.docker/machine/machines/default”
export DOCKER_MACHINE_NAME=”default”
# Run this command to configure your shell:
# eval $(docker-machine env default)
mohammedrafi@NOC-RAFI:~$ docker-machine ls
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
default – virtualbox Running tcp://192.168.99.100:2376 v17.06.2-ce
mohammedrafi@NOC-RAFI:~$ docker-machine create –driver virtualbox –virtualbox-memory “1024” –virtualbox-cpu-count “1” –virtualbox-disk-size “10000” docker01
Running pre-create checks…
(docker01) You are using version 4.3.36_Ubuntur105129 of VirtualBox. If you encounter issues, you might want to upgrade to version 5 at https://www.virtualbox.org
Creating machine…
(docker01) Copying /home/mohammedrafi/.docker/machine/cache/boot2docker.iso to /home/mohammedrafi/.docker/machine/machines/docker01/boot2docker.iso…
(docker01) Creating VirtualBox VM…
(docker01) Creating SSH key…
(docker01) Starting the VM…
(docker01) Check network to re-create if needed…
(docker01) 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: docker-machine env docker01
mohammedrafi@NOC-RAFI:~$ docker-machine ls
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
default * virtualbox Running tcp://192.168.99.100:2376 v17.06.2-ce
docker01 – virtualbox Running tcp://192.168.99.101:2376 v17.06.2-ce
mohammedrafi@NOC-RAFI:~$ ssh 192.168.99.101
The authenticity of host ‘192.168.99.101 (192.168.99.101)’ can’t be established.
ECDSA key fingerprint is d1:bc:18:75:7b:4e:68:dd:ce:68:88:31:fd:71:72:89.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ‘192.168.99.101’ (ECDSA) to the list of known hosts.
mohammedrafi@192.168.99.101’s password:
mohammedrafi@NOC-RAFI:~$ docker-machine env docker01
export DOCKER_TLS_VERIFY=”1″
export DOCKER_HOST=”tcp://192.168.99.101:2376″
export DOCKER_CERT_PATH=”/home/mohammedrafi/.docker/machine/machines/docker01″
export DOCKER_MACHINE_NAME=”docker01″
# Run this command to configure your shell:
# eval $(docker-machine env docker01)
mohammedrafi@NOC-RAFI:~$ eval $(docker-machine env docker01)
mohammedrafi@NOC-RAFI:~$ docker-machine ip docker01
192.168.99.101
mohammedrafi@NOC-RAFI:~$ docker-machine ssh docker01
## .
## ## ## ==
## ## ## ## ## ===
/”””””””””””””””””\___/ ===
~~~ {~~ ~~~~ ~~~ ~~~~ ~~~ ~ / ===- ~~~
\______ o __/
\ \ __/
\____\_______/
_ _ ____ _ _
| |__ ___ ___ | |_|___ \ __| | ___ ___| | _____ _ __
| ‘_ \ / _ \ / _ \| __| __) / _` |/ _ \ / __| |/ / _ \ ‘__|
| |_) | (_) | (_) | |_ / __/ (_| | (_) | (__| < __/ |
|_.__/ \___/ \___/ \__|_____\__,_|\___/ \___|_|\_\___|_|
Boot2Docker version 17.06.2-ce, build HEAD : ff16afa – Wed Sep 6 00:17:25 UTC 2017
Docker version 17.06.2-ce, build cec0b72
docker@docker01:~$ cat /etc/os-release
NAME=Boot2Docker
VERSION=17.06.2-ce
ID=boot2docker
ID_LIKE=tcl
VERSION_ID=17.06.2-ce
PRETTY_NAME=”Boot2Docker 17.06.2-ce (TCL 7.2); HEAD : ff16afa – Wed Sep 6 00:17:25 UTC 2017″
ANSI_COLOR=”1;34″
HOME_URL=”http://boot2docker.io”
SUPPORT_URL=”https://github.com/boot2docker/boot2docker”
BUG_REPORT_URL=”https://github.com/boot2docker/boot2docker/issues”
mohammedrafi@NOC-RAFI:~$ docker-machine ip default
192.168.99.100
mohammedrafi@NOC-RAFI:~$ docker-machine ssh default
## .
## ## ## ==
## ## ## ## ## ===
/”””””””””””””””””\___/ ===
~~~ {~~ ~~~~ ~~~ ~~~~ ~~~ ~ / ===- ~~~
\______ o __/
\ \ __/
\____\_______/
_ _ ____ _ _
| |__ ___ ___ | |_|___ \ __| | ___ ___| | _____ _ __
| ‘_ \ / _ \ / _ \| __| __) / _` |/ _ \ / __| |/ / _ \ ‘__|
| |_) | (_) | (_) | |_ / __/ (_| | (_) | (__| < __/ |
|_.__/ \___/ \___/ \__|_____\__,_|\___/ \___|_|\_\___|_|
Boot2Docker version 17.06.2-ce, build HEAD : ff16afa – Wed Sep 6 00:17:25 UTC 2017
Docker version 17.06.2-ce, build cec0b72
