Using Docker in Skytap Cloud

Skytap recently announced the availability of a Docker template in the Skytap Cloud Public Template Library.  Docker is an open platform for developers and sysadmins to build, ship, and run distributed applications. This new template allows you to easily experiment with or deploy Docker-based containers within Skytap Cloud.

To illustrate this, we’ll do the following:

  1. Create a new Skytap Cloud environment or configuration that is based on this Docker template.
  2. Deploy a Docker Ubuntu container and demonstrate a simple use case as described in the Docker User Guide.
  3. Create a new Docker Ubuntu container and configure it to contain a MongoDB instance and then run it as described in the Docker Examples web page

Create a Skytap Cloud Environment Based on the Docker Template

Once you log into your Skytap Cloud account, navigate to the Template’s tab and search for “Docker” within the “Skytap” templates.

Next, select the drop-down menu associated with the template and choose “Deploy as New Configuration”:

Once the Docker configuration is deployed, start it, get a desktop and log in as user “skytap” to begin interacting with it.

Since our interaction with Docker will be via a command line, open a Terminal window:

Deploy a Docker Ubuntu Container and Say “Hello World”

Now we will use the “docker run” command to launch a Docker Ubuntu container and echo “Hello World”.  Note that the docker command must be run as a super user, so we will prefix the command with “sudo”, which will require an initial authentication step:

After authenticating, the “docker” command executes and, not finding the required specified image locally, pulls the Ubuntu 14.04 image from the “Docker Hub” public repository and runs it with the specified “/bin/echo ‘Hello World’” command.

Create and Run a MongoDB Docker Container

In this example, we will create a new Docker container that is configured with the MongoDB application and then we will run it and interact with MongoDB on the Docker container.

Creation of a Docker container can be automated using a “Dockerfile”.  While we could create the required Dockerfile for this exercise using a text editor, instead we will use the “wget” command to retrieve the example Dockerfile from the Docker Examples document repository.

Now we can issue the “docker build” command to build the MongoDB Docker image and save it in our local Docker repository:

Our MongoDB Docker container has been created and stored locally with the tag “mongodb-repo.

Prior to deploying and interacting with our MongoDB Docker container, we need to install the MongoDB client software on our working virtual machine:

We can deploy and use our newly created MongoDB Docker container with the

command

 

command.

In this “docker run” command, the –d argument runs the container in the background as a daemon.  The –p argument maps the default MongoDB port 27017 to a port on our working virtual machine. The –name argument provides a name for the Docker container to be run.

We can determine the port on our working virtual machine to which the default mongodb port of 27017 has been mapped by issuing the “docker ps” command:

Docker

 

 

 

Here we can see that port 49153 on our working virtual machine has been mapped to port 27017 on our Docker “mongo_01” container.  With this information we can connect to the MongoDB instance running in our Docker container with the “mongo localhost:49153” command:

We can see that the mongo client on our working virtual machine has successfully connected to the MongoDB process on our Docker container.  Additionally we can successfully interact with our Dockerized MongoDB instance.

Summary

We’ve created a Docker environment in Skytap Cloud from the Docker template in the Skytap Cloud Public Template Library and then deployed a simple Docker “Hello World” application.  We then created a more complex Dockerized instance of MongoDB in our Skytap Cloud Docker environment and were able to run, connect to, and interact with it.

The principles demonstrated in these Docker exercises can easily be expanded further into more complex or interesting scenarios based on your requirements.

Please contact Skytap by calling 1-888-759-8278 or visit Skytap.com for more information about Skytap Cloud.

Join our email list for news, product updates, and more.