Docker, Bluemix and the IBM Containers service

Docker is becoming more and more popular. If I look at Docker from the perspective of business value, the following three items jump out at me as being key benefits;

  1. Shorten development cycles and reduced time to market
    • assemble applications as a set of reusable components ie. Docker images
    • reduce dev/QA timelines through repeatable patterns of deployment
  2. Maximise hardware utilisation
    • lightweight containers based on Linux Container technology
    • a container requires significantly less resource than a typical VM allowing for more containers per machine
  3. Deliver cloud ready workloads
    • share Docker images via the Docker Hub (a public registry maintained by Docker)
    • rapidly deploy Docker images on the IBM Cloud leveraging the IBM Containers service on Bluemix

Given my focus on All Things Cloud, I thought I’d explore just how easy it is (or otherwise) to verify point 3 above ie. using Docker to deliver cloud ready workloads. My use case, to take a Docker image running on my local Ubuntu machine and run this same image in the IBM Container service on Bluemix. Given almost all of my dev experience working with IBM has been focused on Java EE, I figured my image should run a simple HelloWorld web app in Tomcat.

1. Installing Docker on Ubuntu & pull an image from Docker Hub

dockerTo get started I installed Docker using the instructions available at With Docker installed, I created a new container using an imaged pulled from Docker Hub. The image pulled from Docker Hub would already have Tomcat installed and ready to go. To run Docker as root, I first issued the command sudo -i in a terminal window.

To pull an image from Docker Hub;

docker login
docker search tomcat
docker pull tomcat:8.0

Docker will then pull an image from the Docker Hub to your local machine. This image already has a vanilla install of Tomcat. If you run this image in a container however, you’ll notice you can’t access Tomcat’s Manager App. I was hoping to use the Manager App to deploy my Hello World web app, but given it wasn’t available, I chose to add a HelloWorld.war using a Dockerfile instead. If you’re keen to understand how you might work with the Manager App on this image, I plan to write another blog post with details so check back again soon.

2. Request access to the IBM Containers service and install the IBM Containers tools 

With Docker installed, a Tomcat image available on my local mahine, I then made a request to access the IBM Containers service on Bluemix.

To request access to the IBM Containers service, simply follow the instructions under the Getting Started section of this article. Basically you’ll need to;

  1. Log in to go to the Catalog and under Integration select Containers
  2. Create a new instance
  3. Wait for notification that your service instance has been activated (you’ll need to wait for a confirmation mail here)
  4. Once activated, access Bluemix, open the IBM Container service
  5. Provide a name for your private Docker image registry and make a note of your API key

After completing the steps above, you’re almost ready to get started with the IBM Containers service on Bluemix. The next step is to install the IBM Containers tools using IBM’s Getting started with Containers documentation. I followed the steps through to Step 3, logging in to Bluemix from my Thinkpad running Ubuntu. Having gotten this far with the IBM Container service, I returned focus to the Tomcat image to deploy on Bluemix.

3. Create a new Image using a Dockerfile

In this section we update the Tomcat image pulled from the Docker Hub by adding our HelloWorld web application. We’ll do this using a Dockerfile that we’ll also use to create a new image. It’s this new image that we then push to Bluemix and run using the IBM Containers service.tomcat

We start by creating a new directory, let’s call it docker, then create a new text file called Dockerfile. The content of the Dockerfile should simply be a few lines like below;

FROM tomcat:8.0
ADD server.xml /usr/local/tomcat/conf/server.xml
ADD HelloWorld.war /usr/local/tomcat/webapps/HelloWorld.war

Essentially all we’re doing here is creating a new image from our Tomcat image and adding our HelloWorld.war file to this image. We also override the server.xml file used by Tomcat to change the default port from 8080, to 80. We do this as the only open ports for Containers and your floating IP address are: 22, 80, 443, 9080, and 9443 on Bluemix.

In a terminal window, from the newly created directory containing both the Dockerfile, HelloWorld.war and an updated server.xml file issue the command;

docker build -t tomcat:bluemix .

When the build command completes, we’ll have created a new image called tomcat:bluemix that includes our HelloWorld.war and an updated server.xml file. It’s the updated server.xml file that allows Tomcat run on port 80, rather than the default port 8080.

To test the new image locally using IBM Containers tools issue the command;

ice --local run -P tomcat:bluemix

Access the Hello World web app via your browser and see things are good. Assuming all is in order, we’re now ready to push this new image to Bluemix.

4. Push the new image to the IBM Containers service on Bluemix

We use the IBM Container tools again to push our image to IBM Bluemix. To get started, login to the IBM Containers service on Bluemix using the following command (remember you made a note of your API key in Section 2);bluemix

ice login -k <API key>

Next we tag and push our image to a private registry on Bluemix by running the following commands:

ice --local tag tomcat:bluemix
ice --local push

Where tomcat:bluemix is the name of the image we created earlier and rodalton is the namespace I used when setting up the IBM Containers service on Bluemix in Section 2.

With our image now on Bluemix, we can run a container using the following command. We use the –name parameter to assign the container a user-specified name, in this case we’ve named the container tomcat;

ice run –name tomcat

Next we’ll assign a floating IP address to the container. Request an IP and make a note of the value returned using the following command;

ice ip request
ice ip bind <Address> tomcat

Where tomcat is the name of our container and <Address> is the IP address you made a note of earlier. We’re now ready to test our application. To do so, simply access your web app via a browser using the IP address assigned earlier. You should see your web app up & running on Bluemix !


I opened this post with the goal of verifying how readily we could deploy a cloud ready docker image on Bluemix using the IBM Container service. To get there, I had to go through some learning, in particular, how to use the IBM Container service and the associated IBM Container tools. All in all, this was a pretty straight forward exercise and now that I’ve done it once, is very easily reproduced. I hope you’ve found this post useful and by all means feel free to post a comment or contact me direct on Twitter @daltonology