Programster's Blog

Tutorials focusing on Linux, programming, and open-source

Ubuntu 16.04 - Ensure Docker Running Overlay2 Storage Driver

Docker supports several different storage drivers, using a pluggable architecture. The storage driver controls how images and containers are stored and managed on your Docker host. When possible, overlay2 is the recommended storage driver. When installing Docker for the first time, overlay2 is used by default. Previously, aufs was used by default when available, but this is no longer the case. OverlayFS is a modern union filesystem that is similar to AUFS, but faster and with a simpler implementation.

Check Storage Driver

Use the command below to check which storage driver you are currently using:

docker info | grep "Storage Driver"

If it says the following, then you're fine and you can leave this tutorial.

Storage Driver: overlay2

However, if it says the following, proceed to Change Storage Driver to Overlay2

Storage Driver: aufs

Change Storage Driver to Overlay2

Run the commands below to switch docker over to using Overlay2

sudo systemctl stop docker
sudo cp -au /var/lib/docker /var/lib/docker.bk
echo '{ "storage-driver": "overlay2" }' | sudo tee /etc/docker/daemon.json
sudo systemctl start docker

Below is a commented version of the script to describe what it's doing

# stop docker
sudo systemctl stop docker

# create a backup of existing setup
sudo cp -au /var/lib/docker /var/lib/docker.bk

# Create the docker deamon config to tell docker to use overlay2
echo '{ "storage-driver": "overlay2" }' | sudo tee /etc/docker/daemon.json

# Start docker
sudo systemctl start docker

References

Last updated: 8th August 2020
First published: 16th August 2018

This blog is created by Stuart Page

I'm a freelance web developer and technology consultant based in Surrey, UK, with over 10 years experience in web development, DevOps, Linux Administration, and IT solutions.

Need support with your infrastructure or web services?

Get in touch