How to change the Docker storage driver
Last updated: July 29th 2024
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.
Note: The storage driver change is necessary only if you run Docker on our legacy LXD servers. If you are using Docker on our KVM servers, this storage driver change is not necessary / recommended.
Prerequisites
- You have Docker already installed.
- You have shell (SSH) access to your VPS.
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 rmi -f $(docker images -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.
Execute the below command to clear the build cache.
$ docker builder prune
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.
Related articles
-
How to install and run Docker containers on a Webdock Ubuntu server
Learn how to manually install and run Docker containers in an optimized way on a Webdock server
Last updated: May 5th 2023
-
How to install and run Docker containers on a Webdock AlmaLinux 8 server
Learn how to manually install and run Docker containers in an optimized way on a Webdock server
Last updated: July 29th 2024
-
How to install and run Docker containers on a Webdock CentOS 8 server
Learn how to manually install and run Docker containers in an optimized way on a Webdock server
Last updated: July 29th 2024
-
How to create and manage docker networks and docker volumes
Learn how to manage Docker networks and volumes in this guide
Last updated: May 5th 2023
-
How to install and run docker containers using docker-compose
Learn how to manage Docker containers using Docker Compose
Last updated: May 5th 2023
-
How to create custom docker images
This guide describes the basic steps to create a custom docker image.
Last updated: October 24th 2022