Docker without Docker

Docker is revolutionizing virtualization, and arguably cloud computing as a whole. Docker runs everywhere, everywhere where you can run Linux that is. If you are running Linux, you are a quick install away from running the Docker client and daemon natively. But if you are on a Mac or Windows, you have to resort to a Linux virtual machine or remote VPS with Docker installed in order to build Docker images and run Docker containers… or do you?

Side note: There is a native OSX Docker client. Available here.

In this tutorial I’m going to walk you through using Docker, but with one big caveat, we won’t be directly interacting with Docker.

Step 1 – Start with a Dockerfile

A Dockerfile  is a text file that can be used to automate the steps you would otherwise take to manually create a Docker image. Everything you need to know about Dockerfiles can be found here. We’re going to use a Dockerfile that we’ve got for a vanilla, out-of-the-box Redis installation. But any other Dockerfile should work just as well. There are a number of public GitHub repositories with Dockerfiles, here we are using one from https://github.com/tutumcloud/tutum-docker-redis

FROM ubuntu:quantal
MAINTAINER Fernando Mayo <fernando@tutum.co>

RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv C7917B12
RUN echo "deb http://ppa.launchpad.net/chris-lea/redis-server/ubuntu quantal main" >> /etc/apt/sources.list
RUN apt-get update
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y redis-server pwgen

# Add scripts
ADD https://raw.github.com/tutumcloud/tutum-docker-redis/master/run.sh /run.sh
ADD https://raw.github.com/tutumcloud/tutum-docker-redis/master/set_redis_password.sh /set_redis_password.sh
RUN chmod 755 /*.sh

EXPOSE 6379
CMD ["/run.sh"]

Use your favorite text editor to copy/paste or create and save your Dockerfile locally. (Preferably, name the file Dockerfile).

Step 2 – Build Dockerfile

Now, if we were running the Docker daemon, locally or remotely, we could build the Dockerfile and create a Docker Image. But the whole purpose of this tutorial is to do without Docker. So, instead, we’re going to use a hosted Docker registry called Quay.io

If you haven’t registered already, I encourage you to do so and create a free account at Quay.io You will not regret it, plus they offer an awesome free tier for public repositories.

In Quay.io the first thing we want to do is to create a new repository. Make sure to select “Initialize Repository from Dockerfile.” Choose the Dockerfile we created earlier from your local disk, and click on “Create Repository.”

Screen Shot 2014-01-25 at 2.38.55 AMAfter that, your milage may vary, but Quay should have your image built in a matter of minutes. Wait for that before continuing with this tutorial.

Cool! You’ve now got you very own image built from the Dockerfile you wrote/copied, and you haven’t even touched a Docker client/daemon yet.

Step 3 – Import Image

Before we are able to run a container from the image we just created, we need to import said image (repository) into Tutum. If you haven’t done so already, now is a good time to create your free account at Tutum.

On the left-panel, go to “Private Registries” then click on “Actions > Manage users” for Quay.io, as shown in the image below.

Screen Shot 2014-01-27 at 1.41.40 PM

In the modal that comes up, fill in with your Quay.io credentials, this will enable Tutum to connect to Quay.io and pull the images (repositories) right from Quay’s registry.

Next, on the left-panel, click on “Private Images” and then the button “Add private image”. You’ll get a modal like the one below. You’ll have to add the name of the image (repository) – the name must match the one you created earlier at Quay.io. Finally, just add a description, and click Save.

Screen Shot 2014-01-27 at 1.43.37 PM

You should now see the image (repository) from Quay.io listed along with your other Private Images at Tutum.

Screen Shot 2014-01-27 at 1.49.12 PM

Great! Now let’s move on to actually launching our container.

Step 4 – Launch Container

In Tutum, click on “Containers” on the left-panel. Then click on the green button that reads “New container”. Since we’ll be using an image from a private registry, click on the last tab from the modal, “Private registry”. You should see the image from Quay.io listed here.

Screen Shot 2014-01-27 at 1.52.43 PM

Select the correct tag for this image (most likely it will be “latest”), and click on “Select”. In the next screen you can configure the container by giving it a name, choosing a container size, defining the Docker “run command” and adding/removing ports.

Screen Shot 2014-01-27 at 1.55.14 PM

Click “Finish” to launch your new container. You will see your container launching in a matter of seconds (YMMV depending on the size of the image).

Step 6 – Test Container

After your container has successfully started, in order too see the container details, click on the magnifying glass next to the container’s name. From here you can see all of the container’s information, including mapped ports, as well as logs and monitoring information (CPU, Network, Memory, Disk).

Screen Shot 2014-01-27 at 1.59.33 PM

We can gather that the hostname for our container is: No-Docker-Redis-borjaburgos.perses.tutum.io and Redis is listening on port: 49180

Furthermore, this particular image of Redis we chose prints the password in the Logs, as shown in the image below:

Screen Shot 2014-01-27 at 2.02.59 PMWe now have all the information we need to access our Redis container. Let’s launch a local Terminal and try it out:

Screen Shot 2014-01-27 at 2.05.47 PMSUCCESS!!!!

Step 7 – Conclusion

We have been able to go from zero to running a custom Docker container without directly interacting with the Docker client or daemon, that’s impressive!

There are a number of key features currently under development that will allow you to do more advance deployments, such as container linking, scaling, persistent storage, and tight integration with private registries, such as Quay.io. Recently, we also made our API publicly available, and we will soon be releasing a CLI and accompanying Python Library to interact with Tutum programatically.

To get notified of our next blog post with more Docker tricks and tutorials, and cool and innovative ways to deploy using Tutum’s infrastructure, please sign up at the bottom right corner, or follow us on Twitter at http://twitter.com/tutumcloud.

Borja is a co-founder and the CEO at Tutum. Borja holds a MSc in Information Security from Carnegie Mellon, a MSc in Applied Informatics from University of Hyogo, and a BSc in Computer Engineering from Georgia Tech. In his previous life he worked as a R&D engineer developing location based services, and later as a tech consultant for large Telecom providers around the World. Borja describes himself as a tech entrepreneur, hacker and DIYer. When not working on Tutum, Borja likes to tinker with hardware and build things.

Tagged with: , , ,
Posted in Tutorial
4 comments on “Docker without Docker
  1. Hi, the official Docker index (https://index.docker.io) now supports private image hosting. It would be great to have the same tutorial with official Index integration.

  2. borjaburgos says:

    Hi Solomon, most definitely, we’ll be supporting Docker’s private image hosting, and we’ll write a post on that. Having an API to list a user’s private/public images would be awesome, can we expect that soon? Also, we’re making some key changes to Tutum and would love to get some feedback. Cheers!

  3. Noah Rivera says:

    Lovely website, it loads genuinely quick and looks really cool.

Leave a Comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories
%d bloggers like this: