Tutorial on how to configure and run a Docker container within a
host that is running the CoreOS operating system. The tutorial uses
Vagrant to launch a VM capable of deploying and running Docker
containers.
Note
CentOS hosts are known to have filesystem/mapper issues when run on Vagrant and attempting to
launch a container through Docker. It’s better to run the Linux host natively, or use something
else like CoreOS, which is why this tutorial was put together.
Process
Install VirtualBox and Vagrant.
Install the CoreOS plugin for Vagrant.
Boot the CoreOS host via Vagrant (Docker should already be installed). After creating the VM, SSH
into the host using the native Vagrant commands:
Note: All following commands will be run from within the CoreOS host.
Create a Dockerfile on the CoreOS VM containing the following:
Create the Docker image (assuming you are in the same directory as the previously-created Dockerfile):
Inspect the images repository to see that the newly-created image exists:
(Optional) You can also test the image quickly to ensure that it functions as expected:
Now that we have a fully-functioning base CentOS 5 image, create a directory structure for the
required/desired containers to be run and hosting the respective software:
Next, create a Dockerfile in each previously-created software directory. This is an example
of one corresponding to the ActiveMQ container desired (file is ActiveMQ/Dockerfile). The
instructions in the Dockerfile assume that there is a directory shared/ which contains the
configuration files and packages desired/to be copied to the container:
Next, we will use the Dockerfile to create a new image using the specified ActiveMQ/Dockerfile
file, which uses the base CentOS 5 image we created earlier:
Now that the ActiveMQ image has been created, you can create as many containers using the image
as you would like. These are examples of different ways to launch a container using the amq image:
Extra Commands
This is a list of useful commands to interact with Docker: