How to change the Docker storage driver

Last updated: April 5th 2022

Introduction

This guide helps you change the Docker storage driver to fuse-overlayfs. This reduces Docker’s high disk space usage (a side effect of vfs storage driver) and makes container deployment a bit faster.

Prerequisites

  • You have Docker already installed.

Note: Before proceeding through the rest of the guide we recommend you take a Webdock snapshot of the current state of your server as we will be removing existing Docker containers and images. So having a backup gives you a chance to roll back your server, if things go sideways.

Removing Containers and Images

Execute the below command to stop and remove all the containers. Any data that is inside the containers (that you may have temporarily saved) will be lost.

$ docker stop $(docker ps -a -q)
$ docker rm $(docker ps -a -q)

Execute the below command to remove all the images.

$ docker rm $(docker ps -a -q)

This will free up the space used by Docker images. But this will preserve all the user-created Docker volumes, custom Docker networks, and the data stored on /other/system/path as they are.

Changing storage driver

Now depending upon the distro you are on (Ubuntu / Debian, CentOS 8 / AlmaLinux 8) use the package manager (apt or yum or dnf) to install fuse-overlayfs.

For Ubuntu / Debian:

$ sudo apt install fuse-overlayfs

For CentOS 8 / AlmaLinux 8:

$ sudo yum install fuse-overlayfs

Now make changes to the Docker daemon.

$ sudo nano /etc/docker/daemon.json

Then paste the below content to the above file and save it.

{
  "storage-driver": "fuse-overlayfs"
}

Finally restart the Docker daemon to apply the changes.

$ sudo systemctl restart docker

Now run the below command to check if the new storage driver is effective.

$ docker info | grep "Storage Driver:"

You should see the following output.

Storage Driver: fuse-overlayfs

That’s it. Now you have successfully changed the Docker storage driver. Pull the images again and deploy your containers with either Docker run - with the same port and volume mappings - or with docker compose, whichever way you prefer.

Conclusion

This guide outlined steps on how to change the storage driver of Docker.

We use cookies. Please see our Privacy Policy.