This tutorial shows you how to use Docker Machine with the OpenStack driver
to provision Docker Engines on Catalyst Cloud compute instances.

Docker Engine is the daemon at the core of the Docker platform. It is
responsible for providing the lightweight runtime on which containers are run.

Docker Machine is a tool that allows you to provision Docker Engines either
locally or hosted with a cloud provider. Docker Machine has a number of
different drivers to facilitate installing the Docker Engine on different cloud
providers. On the Catalyst Cloud we will be making use of the OpenStack
driver.

Once a Docker Engine has been provisioned on a VM instance, the local docker
client can be configured to talk to the remote Docker Engine, rather than
talking to the local Docker Engine. This is achieved using environment
variables.

Assumptions: your project has a private network, subnet and router set up. Please see consult Overview if you do not have this configured already.
It is also assumed that you have spare floating IPs available in your quota.

The next step is to set up a security group for your docker host. You will use the
command line clients to achieve this. First create a security group:

If you are unsure of what YOUR_CIDR_NETWORK should be, ask your network
admin, or visit http://ifconfig.me and get your IP address. Use
“IP_ADDRESS/32” as YOUR_CIDR_NETWORK to allow traffic only from your current
effective IP.

The next step is to provision a compute instance using Docker Machine. Docker
Machine will instantiate a VM, get SSH access to this VM and will then install
the Docker Engine on this host. As this process can take quite a while, it’s
a good idea to use the --debug flag so you can monitor the installation
progress and see any errors that may occur.

Note

You are making use of OpenStack environment variables in this command. Ensure you have followed the steps described at Source an OpenStack RC file

If your cloud project only has one private network defined, then the
--openstack-net-namePRIVATE-NET-NAME can be omitted. If there is more
than one private network defined, then PRIVATE-NET-NAME should be replaced
with the network you wish to connect the docker-engine-host to

Now you need to tell your local client how to connect to the remote Docker Engine
you have created:

$ eval"$(docker-machine env docker-engine-host)"

Now, when you issue docker commands using the local client, you will be
interacting with the Docker daemon in the cloud instance:

Next, create a test image from which you will instantiate a container running in
the cloud. You will run a simple webserver by basing your image on the official
Nginx image. To create a custom index page and a Dockerfile for our
image: