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