For now, I was using Docker with devicemapper on my personal servers. As long as I considered Docker an early test, this was okay. But now I want to move some of my personal infrastructure into containers while also building an automatic service discovery environment for further test containers. Thus I wanted to skip to a faster storage driver. You can find a lot of material about Docker storage drivers in the net, there are several, each having its own pros and cons. If you want to read more into the issue, check the end of the post.
I decided to use OverlayFS for several reasons, integration in the Linux kernel since 3.18 (in combination with a rename to simply overlay) being the major one. Here’s what I needed to do.
1. Kernel upgrade
Although CentOS uses the "old" kernel 3.10, there are a lot of backports, including overlay. As overlay-support was lackluster on 7.1, I still opted to do a kernel upgrade even on CentOS 7.2. If you're running CentOS 7.2, you can try to skip this step. I'd really appreciate a confirmation afterwards
Update 2016-01-29: While testing overlay on kernel 3.10, I got errors while running docker build. Specifically I got errors when doing an rm on files of an underlying layer. Therefore I’d still recommend using a newer kernel.
We need to upgrade the kernel first. You can either compile it your own or use one from a custom repository. Both ways are described on Linoxide, so I don’t need go into further detail here. I used the kernel-ml package from ELRepo:
Don’t reboot yet, we want to make at least one more change and this way you can directly see if every change is reboot safe.
2. Update system settings
We’ve upgraded the kernel, but the systemd Docker service will still use the devicemapper. So we need to change the systemd service file.
Don’t restart the service yet as the overlay storage driver doesn’t work with the old 3.10 kernel.
Additionally we need to make safe the overlay module is loaded on startup.
3. Create a new partition for /var/lib/docker (Optional)
If you’re extensively testing Docker and /var/lib/docker is not on a dedicated file system, it might happen you’ll be running out of inodes quickly. So I recommend creating a new partition for the directory. This highly depends on your setup, I’ll just describe mine using LVM.
Now we can reboot. Afterwards check if everything is working as intended by using docker info:
That’s it! You’re now using overlay(FS) as a storage driver for Docker. Enjoy the improved speed. If you newly created a partition for /var/lib/docker, don’t forget to delete the old content of the directory after some days of testing.