2 Ways I'm using Docker29 Apr 2015
I recently got to migrate my server from running Ubuntu 12.04 to Ubuntu 14.04. As I was unable to upgrade the kernel while on 12.04 (due to some hardware issues), I was stuck running into the bug mentioned on the installation page. It wasn’t too big of an issue but, basically sometimes containers would just hang for no real reason. In this state I couldn’t stop them or delete them. The only way to get rid of them was to either restart docker or restart the server.
Anyways, I’m happy that is no longer an issue for me. So I’ve been looking into moving as much as I can into Docker. I basically have two ways that I’m using it. The first of which is the one that I mention in Docker Appliances, I’m running my Discourse server in Docker using the execellant discourse_docker project. It works extremely well, expecially now that it doesn’t hang randomly.
The other way I’m using it is as the execution enironment for a couple of other things. What I mean by this is that both the code for the site and the database files are mounted from the host. Here is an example, this site runs in a Docker container. On my server, its code and database reside at
/var/node/ruin. Since I last wrote about Ghost, I have switched over to using SQLite as my database. SQLite performance is adequate for my needs and at the time, I hadn’t figured out how to get MySQL up and running in a Docker container. So the docker container simply mounts the code/content directory and runs only the node process. I have it set to expose the default port that Ghost runs at, 2368, to the docker host. On the docker host, I run nginx and reverse proxy the traffic to port 2368. When I want to update the code, I have an ansible playbook that pulls the fresh code down, stops the current container and launches a new one.
I also have a similar set up for my unmark instance, unmark.tobolaski.com (I wouldn’t recommend going there as it uses a custom certificate authority). It mounts the code from
/var/unmark/app and the mysql data on
/var/unmark/mysql into a lamp container. In this case, I have nginx setup to reverse proxy to 8000 which is mapped to 80 on the Docker container.
If I was going to be putting either of these containers on multiple hosts, I’d move the database into something else, possibly a new container or maybe their own host. Then I add in the application code into the container and distribute it as a single unit, which is more like the intended usage than what I’m currently doing. Basically I’m using docker as lightweight virtualization, which it does extremely well.
I’ve open sourced both of the dockerfiles that I discussed here.