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:
To verify what storage driver used:
Okay, let’s begin to change the storage driver from AUFS to OverlayFS.
Lots of tutorials online including this one and this one, suggest to provide an option in /etc/default/docker
.
or
Unfortunately, it didn’t work for me. But when I started docker using upstart command as the following:
the storage driver has changed to “overlay” correctly!
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.
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!
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:
Now, start docker service with systemd again:
We can verify it by running ‘docker info’:
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.
Happy dockering!