Skip to main content

Continuous Blogging - Migrating to Docker Cloud

·3 mins

Up until recently, this blog was running on a CoreOS host at DigitalOcean. It is still running at DigitalOcean, but the process of updating the blog changed.

Whenever I had to change something, I

  • logged in, either via SSH directly or docker-machine,
  • pulled the GIT repo,
  • rebuilt the docker image and
  • updated the container.

Not really elegant. Time for a change and simplify the process.

How am I doing it now? Easy …

  • Finish the blog post.
  • Create the docker image that basically holds nginx and the content.
  • Push the docker image to the Docker registry.
  • Wait a little.
  • Read the new blog post online.

How did I do that? Easy …

As a heavy user of docker-compose, everything came together using Docker Cloud and its service stacks. Instead of writing a docker-compose.yml one is required to create a very similar looking docker-cloud.yml. I already had a virtual machine at DigitalOcean, I could just link my two accounts and get the docker-cloud client

alias docker-cloud="docker run -it -v ~/.docker:/root/.docker:ro -v `pwd`:/root --rm dockercloud/cli"

A service can be set to redeploy, so whenever there is a change of the image, the service container will be updated with that new image.

All in all, the creation of the blog-post is all done with docker. There is no single tool that I need on my Mac to create the HTML with Jekyll. Only need an editor to write the text and Docker itself.

Here are some commands to describe the workflow in more detail.

The initial creation of the service stack, whereas the docker-cloud.yml is very similar to a docker-compose.yml.

docker-cloud stack create -f /root/docker-cloud.yml
docker-cloud stack start root

This can also be done in one single command, but I prefer two separate steps.

Whenever there is a change to the service stack itself by modifying the docker-cloud.yml I only have to type, e.g. when changing some configuration of the load-balancer:

docker-cloud stack update root -f /root/docker-cloud.yml
docker-cloud service redeploy lb-prod

Why am I using a load-balancer? Easy …

Actually, I run two containers with two different versions of the blog, whereas one is the actual live version that you are seeing right now and the other one is a preview where I check my drafts before really finalizing them.

The load-balancer just checks the subdomain being used and redirects the request to the corresponding container.

Actually, this is not, let’s say “true”, continuous deployment. It is only continuous from the point of pushing the image, but not the actual source. In a next step I will tackle this as well using the build-jobs of the Docker Cloud itself.

Done for today!