Using the full potential of Docker on a Digital Ocean VPS requires a little bit of extra configuration. This article discusses what is involved.

Initial VPS creation

There's nothing very special here. I tend to prefer Ubuntu distributions (just what I'm used to - I have nothing against other Linux distributions). I'm going to assume you're installing a stock Ubuntu 14.04 distro for the purposes of this article.

Once I've spun up the droplet[1], what I tend to do is log in as root to run the following:

apt-get update
apt-get upgrade -y

This just gets things into a nice and tidy place for the next couple of steps.

Enabling kernel accounting

Being the VPS is running in a virtual machine, modifying the kernel boot parameters to enable accounting via grub is simply ignored. The kernel image is controlled by the virtual machine config, and there is nothing that can be done once the machine is running to change the kernel params. To get around this, Digital Ocean has enabled a mechanism to signal to the virtual machine hypervisor that a different kernel should be used. And being such kind people, they regularly create point-release kernel images with parameters that enable kernel accounting.

So, to switch on accounting, it's a matter of changing our kernel to one that has it switched on. My approach to this is to find the next highest point release from the default image, and change to that.

For example, I recently created a new droplet, and the kernel it installed was

Ubuntu 14.04 x64 vmlinuz-3.13.0-57-generic

I then went to the Digital Ocean control panel, selected my new droplet, selected 'Settings', and then selected 'Kernel'. This panel allows changing of the kernel. With the droplet still powered on, click the dropdown box in the panel to show a (very large) list of new kernels to choose. Find the closest kernel release to your current one that has the string -docker-memlimit appended to it, and chose that. Click the 'Change' button. The panel should look like this:

Linux kernel selection for Docker

Following the instructions in the panel, log into the box, and shut it down from the command line:

shutdown -h now

Give it a moment, then switch to the 'Power' control panel. Power it up from there, give it another few moments, and the kernel is now fully operational. Whether your friends arrive or not.

Who's your daddy now?

Installing Docker

Those whacky Docker engineers have made available a really nice installation method for the adding Docker to your system. Simply run the following as root:

curl -sSL | sh

And bingo! All is good. You now have Docker on your system, with the ability to do things like restricting swap usage for containers! Yippee!

  1. This is Digital Ocean's "cute" name for a VPS. ↩︎