As of today, the default storage for Docker on (K)Ubuntu 15.10 is AUFS. I want to switch it to OverlayFS. Personally, I’m still new to Docker, but I did hear that OverlayFS is better than AUFS. You can read more about OverlayFS here.
Anyway, the purpose of this post is how to switch OverlayFS and avoid head-scratching.
On Ubuntu 15.10 (wily), one can start/stop services either using Upstart or systemd. Since I want to get more accustomed to using systemd, I’ve been trying to use it anywhere possible. For example, here’s the command to start docker:
$ sudo systemctl start docker
To verify what storage driver used:
$ docker info Containers: 0 Images: 0 Server Version: 1.9.1 Storage Driver: aufs Root Dir: /var/lib/docker/aufs Backing Filesystem: extfs Dirs: 0 Dirperm1 Supported: true Execution Driver: native-0.2 Logging Driver: json-file Kernel Version: 4.2.0-19-generic Operating System: Ubuntu 15.10 CPUs: 4 Total Memory: 7.663 GiB Name: f9470m
Okay, let’s begin to change the storage driver from AUFS to OverlayFS.
Unfortunately, it didn’t work for me. But when I started docker using upstart command as the following:
$ sudo service docker start
the storage driver has changed to “overlay” correctly!
$ docker info | grep -i driver WARNING: No swap limit support Storage Driver: overlay
It took me awhile to figure out that the option provided to
/etc/default/docker is only for Upstart.
Well, now I at least know which direction; or questions I should ask Google. Docker has an article explaining how to control docker with systemd. With that, I was able to adapt it to pass an option to systemd docker.service to use OverlayFS.
Here’s how I did it.
First, I ensure that docker is not running.
$ sudo systemctl stop docker
If docker was started with Upstart use (
$ sudo service docker stop instead.)
In my case, since I just started running Docker on this machine, I didn’t have any images or useful files. So I took an extra step to remove old AUFS files. You may need to think twice before running the following command. You might lose your important data!
If you’re unsure, don’t run it. You’ve been warned!
$ sudo rm /var/lib/docker -rf
Then create a directory, if not yet exist,
/etc/systemd/system/docker.service.d. Create a file, call it whatever you like. I named it overlay.conf with the content:
[Service] ExecStart= ExecStart=/usr/bin/docker daemon -H fd:// --storage-driver overlay
Now, start docker service with systemd again:
$ sudo systemctl start docker
We can verify it by running ‘docker info’:
$ docker info Containers: 0 Images: 0 Server Version: 1.9.1 Storage Driver: overlay Backing Filesystem: extfs Execution Driver: native-0.2 Logging Driver: json-file Kernel Version: 4.2.0-19-generic Operating System: Ubuntu 15.10 CPUs: 4 Total Memory: 7.663 GiB Name: f9470m
It’s working! Oh, if you’re wondering why I can just run docker command without prefix with sudo; it’s because my user account is docker group.