Managing your own Docker Host with XOA

Watch out! This tutorial is over 2 years old. Please keep this in mind as some code snippets provided may no longer work or need modification to work on current systems.
Tutorial Difficulty Level    

If you read our recent tutorial series on using Docker Containers via a web frontend you may also be curious about Docker on the command line.

For those seeking that extra bit of experience, we have created a Docker Host (with Dockly) template inside our Virtualisation Environment here at DkIT. This allows you to run your own Docker host (or cluster via Swarm mode)  and take full control of everything. You can manage your own images and containers at the command line, but still access the DkIT Registry for Push/Pull of images. Let’s take a closer look with an example project.

Login to and fire up a new VM with the Docker Host (with Dockly) template provided.

You will be able to SSH to your new host (even from Windows, natively or with PuTTY) with the usual credentials for all VMs.

Once you have done this, let’s create a directory to keep all out Dockerfiles in, and a sub-directory of that for our app (which will be a simple script to let a user send a pre-formatted tweet). This is good practice and something you should always do.

So far so good. Now to actually start doing Docker stuff. In order to build our image, we need any resources it will utilise plus the Dockerfile to build it. We’re going to create an index.html file and a PNG image (of a Linux penguin) that will be copied into our eventual container.

First, acquire the image from a remote location using the wget command.

Now create the index.html file with nano. In there goes all the code our web app will use (mostly html and css).

It’s time to create out Dockerfile! Name the new file just that, “Dockerfile” and put the following in there:

As you can see, we are using the official nginx image as our base, copying our files to the correct locations in the system, opening port 80 and finally running the nginx command using the switches explained in  a previous tutorial. You’ll notice we don’t use ENTRYPOINT as before. However, The CMD specifies arguments that will be fed to the ENTRYPOINT, so it’s the same result. We’re just mixing things up a bit.

Now we can Build our image. We want to tag it locally as “tweetapp”, so the command is:

docker build –tag=tweetapp .

Here’s the output:

Looks good. A quick docker image ls will show our image now exists in Docker, along with the nginx image it depends on.

Great! Now let’s fire up a container and see if our code actually works. The command to use here is:

docker container run –detach -p 80:80 tweetapp

This will start and map port 80 on the container to port 80 on our VM. Run dockly to see your container details:

Dockly has some nice features, like quick stopping and restarting of your container, as well as easy removal and comprehensive info about a container at the touch of a button (i):

You can now visit your VM’s IP Address in a browser to check the output of your web app.

Wow, that look’s promising! Just test your Tweet button to be sure:


Our image has now been proven to work, and could actually be useful. We should tag it for addition to the DkIT Registry so we can use it again later (ie. Pull) from future instances of the Docker Host (with Dockly).

As we’re adding to the share registry, we should tag it appropriately with using our student ID.

docker build – .

and Push it to the registry

docker push

(read lots more about the power of tagging here and how to tag AFTER the image is created here).

We can check that was uploaded properly by visiting the registry in our browser (only works inside the college).

Much success!

Did we mention this now means your image is available to Pull from other Docker hosts in DkIT?

docker pull

Did we mention this includes Because it does! Check it out:

And when deployed:


So have fun, the more you try, the more you will learn about Docker.

Here is a quick cheat sheet of the commonly used commands to get started:

Build an image docker build –rm=true .
Install an image docker pull ${IMAGE}
List of installed images docker images
List of installed images (detailed listing) docker images –no-trunc
Remove an image docker rmi ${IMAGE_ID}
Remove all untagged images docker rmi $(docker images | grep “^” | awk “{print $3}”)
Remove all images docker rm $(docker ps -aq)
Run a container docker run
List containers docker ps
Stop a container docker stop ${CID}
Find IP address of the container docker inspect –format ‘{{ .NetworkSettings.IPAddress }}’ ${CID}
Attach to a container docker attach ${CID}
Remove a container docker rm ${CID}
Remove all containers docker rm $(docker ps -aq)

There’s also an excellent article covering the basic commands here.