Docker uses the DeviceMapper storage driver as default if no other driver is available. That's ok and it works, mostly. I run, sometimes into trouble, because the container could not be started. At the end, I have to delete Docker container and images and create it again. The OverlayFS driver is faster than DeviceMapper and aufs. You can also read more about OverlayFS on Docker.com. In this Blog post you will learn how to configure your Linux system and Docker to use the OverlayFS storage driver.
Check current Docker storage driver
If you not have Docker currently installed, skip this section and go to Configure Docker with OverlayFS. Otherwise run the command docker info
to see information about your Docker environment. Important is the storage driver. If you not already using OverlayFS as the Docker storage driver, you see something like devicemapper or aufs. The following output shows that the OverlayFS storage driver is used.
Containers: 14
Images: 501
Server Version: 1.9.1
Storage Driver: overlay
Backing Filesystem: extfs
Execution Driver: native-0.2
Logging Driver: json-file
Kernel Version: 3.19.8-031908-generic
Operating System: Ubuntu 15.04
CPUs: 8
Total Memory: 7.73 GiB
Check if OverlayFS is available
Depending on your Linux version, OverlayFS is not in the Linux kernel upstream. However, to check if OverlayFS is already installed, run the command lsmod | grep overlay
. If you get an output with overlayfs, you are ready to enable OverlayFS in your Docker config.
If you have no output, check your Linux kernel version with the command uname -a
. You should see somthing like that: Linux ThinkPad 3.19.8-031908-generic #201505110938 SMP Mon May 11 13:39:59 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux. The Linux kernel version here is 3.19.8. OverlayFS is available since linux kernel 3.18.
Upgrade Ubuntu kernel
If OverlayFS is not available on your system you can simply upgrade your Linux kernel to a newer version. The current example uses the kernel version 4.3 for a 64 Bit system, but you are free to use another kernel version >= 3.18.
$ wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.3-wily/linux-headers-4.3.0-040300-generic_4.3.0-040300.201511020949_amd64.deb
$ wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.3-wily/linux-image-4.3.0-040300-generic_4.3.0-040300.201511020949_amd64.deb
$ wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.3-wily/linux-headers-4.3.0-040300-generic_4.3.0-040300.201511020949_all.deb
$ sudo dpkg -i linux-headers-4.3.0*.deb linux-image-4.3.0*.deb
Now reboot your system and check if OverlayFS is available (see above).
Another possibility to use a different storage driver than devicemapper is to install the linux-image-extra kernel with the command sudo apt-get -y install linux-image-extra-$(uname -r)
, if you can't upgrade your Linux kernel.
Configure Docker with OverlayFS
To enable OverlayFS for Docker open /etc/default/docker
and put the following line DOCKER_OPTS="--storage-driver=overlay"
at the end of the file. Restart the Docker daemon with sudo service docker restart
or install Docker now and check if Docker uses OverlayFS (see above).
Conclusion
Using Docker with OverlayFS is easy and there is a better performance. You should also use the OverlayFS Docker storage driver for development. Now, I'm waiting for User Namespaces to avoid the file permission issues in development. guso is not an option. Don't forget to enable Logrotate for the Docker log files.