Getting started with Docker in minutes using Docker Machine

Docker is an open source platform designed for system administrators and
developers to deploy applications. There are a number of tools around the
Docker ecosystem which make it easier to get started with Docker, one of them
is the recently released (but still in alpha): Docker Machine.

Docker Machine allows you to deploy Docker hosts using a simple command.
Typically, you would have to create a new virtual machine, install multiple
Docker components until you’re ready to provision new containers. With Docker
Machine, it’s a matter of a single command.

Installing Docker Machine

Docker Machine is a tool which is installed on your local machine which takes
care of deploying a new instance and installing Docker on it. It’s currently
still in alpha, but you can always download the latest release from GitHub.

Once you download the appropriate binary for your operating system, it’s best
to move it to /usr/local/bin/ so that you can easily access the command again,
installing the latest release at the time of writing th is article (which isv0.1.0-rc4) should look like this.

Configure Environment Variables

When Docker provisions a new instance, it can use the common OpenStack
environment variables for your credentials to reduce the number of command-line
arguments you have to provide and make it easier for you to use.

You can setup your credentials by logging into the CloudConsole control panel,
navigating to the “API Credentials” button and you’ll see them listed under theopenrc file section, they will be similar to the following:

You can either save this in a file called openrc and then calling it by
running source openrc or you can simply run those commands in your shell
before moving on.

Create Docker Instance

Once you have all the correct information, you can proceed to create your new
Docker instance. You will need to provide a flavor and image ID when creating
this new instance, so we’ll use the nova CLI commands to get it.

$ nova image-list | grep 'Ubuntu 14.04'
$ nova flavor-list

With these commands, you’ll be able to find the Ubuntu image UUID and you can
select the flavor you wish to use. In our case, we’ll use the current Ubuntu
14.04 LTS image (uuid: dc808930-9d49-4a27-b71a-77e12a3c5b54) and the nb.2G
instance type (uuid: 8c6a8477-20cb-4db9-ad1d-be3bc05cdae9).

The process will take a few minutes, it will provision a new instance in your
cloud account, install the latest release of Docker on it and store the required
information on your machine to access it using the Docker client. If you have
the docker CLI installed, you will be able to manage it by using the env
tool within Docker Machine.

$ $(docker-machine env docker-1)
$ docker ps

Now, you can create new containers easily without having to SSH to the host as
well. All communication is encrypted using TLS to the remote Docker instance.