By now, we’ve all heard “Docker, Docker, Docker” coming from every available channel. Ok, we get it, Docker’s great. But why would I want to use it on a Virtual Private Server?
Let me first outline why I chose to investigate it and ended up falling in love. I am often called upon to provide web accessible demonstration sites for clients using one piece of software or another. It’s simply not good enough to point them to the software developers existing demonstration site. You have to be able to prove that you can work with it and satisfy the client’s particular requirements, be it simply modifying the site appearance or enhancing the fuctionality with custom modules. These application requirements can vary wildly e.g.
- Sourcefabric Live Blog – Ubuntu 12.04, Python3 and Mongrel2 server
- Sahana Eden – Debian, Python 2.6 and Apache2 server
- Redmine – Ruby, Rails
These requirements could involve adding additional repositories to your server environment, modify your VPS configuration and eventually “breaking” it.
Previously I have used virtualbox to create these environments with each machine having it own operating system web and database servers to avoid crashing my host machine. This result in duplication accross machines and occupies a great deal of disk space. Even when developed locally, there is no guarantee you can replicate that environment on your VPS.
I wasted so much time and effort building these different environments that I decided to take a leap of faith and investigate Docker …… What a time saver!!
I can use multiple language versions without having to resort to all the hackarounds for the language (python, ruby, java, node). Want to run a Python program in Python 3, but only have Python 2 installed on your host? Run it using Python 3 image. Want to compile a Java program with Java 1.6 instead of the 1.7 that’s installed on your machine? Compile it in a Java 1.6 Docker image.
Deployment is easy. If it runs in your container, it will run on your server just the same. Just package up your code and deploy it on a server with the same image or push a new Docker image with your code in it and run that new image.
You can still use your favorite editor/IDE as you normally do. No need for running a VM in VirtualBox and SSHing in and developing from the shell just so you can build/run on a Linux box.
A 64 bit 3.10 Linux kernel is the minimum requirement for Docker. Kernels older than 3.10 lack some of the features required to run Docker containers. These older versions are known to have bugs which cause data loss and frequently panic under certain conditions. From my own experience this means provisioning a KVM box on BHost as the OpenVZ containers use an older kernel. To their credit BHost does not charge more for this option plus it gives you the advantage of a full hardware virtualisation platform with loadable kernel modules, giving users the freedom to run a range of Linux distros with any kernel. Each virtual machine has private virtualised hardware including network card, disk and graphics adapter, and with no possibility of overselling, you get guaranteed resources at your disposal any time day or night!
Docker installation is a breeze, simply a matter of adding the docker software repository to your system package manager and install as you would any other package. Full instruction for installation on many different flavours of Linux, together with Mac and Windows (if you need it on your local machine) can be found on the docker website, together with other comprehensive documentation to get you started.
I will be following up this article with a number of tips and tutorials to help you set up a fully containerised environment on BHost.