Tuesday, December 29, 2015

Docker Machine Introduction

This is a short post that introduces the docker-machine tool, which is part of the docker toolbox.

Overview

Docker-machine is a command line interface (CLI) dedicated to manage virtualization environments in order to provision a minimal docker environment.

Virtualization environments can be hypervisors (VMware, VirtualBox)  or cloud providers (AWS, Azure, etc) . Docker-machine uses drivers to manage virtualization environments.You can find the complete list of supported drivers here.

Fig. 1 - Local and Remote Virtual Machines

Since Docker only runs on Linux, each Virtual Machine is created with a Linux based Operating System. For local VM, the base OS is boot2docker and for remote VM within a cloud, the base OS is Ubuntu.

Fig. 2 - Virtual Machine creation
You can choose other Operating System (list) from:

  • RancherOS
  • Debian
  • RedHat Enterprise Linux
  • CentOS
  • Fedora

but be aware that, except for RancherOS, all other OS are considered as experimental.

When using a cloud provider, it's possible to specify the desired image that will serve to create the Virtual Machine. You will then use the corresponding driver option.


Finally, docker-machine will configure the docker client to connect to the docker engine created previously:

Fig. 3 - Docker client configuration

The configuration is done through environment variables within the current user session:

  • DOCKER_TLS_VERIFY
  • DOCKER_HOST
  • DOCKER_CERT_PATH
  • DOCKER_MACHINE_NAME

The docker client will retrieve the values of these environment variables and use them to establish a connection to the Docher Engine and manage it.

Installation

Docker-machine can be installed through the docker toolbox package (recommended) or directly following this documentation.