Pre-requisites
To fix “Docker no space left on device”, you have to use the Ubuntu 20.04 Linux system and docker installation in it. If Docker is not installed, you can do it with the help of the below-listed command in the terminal
Method to fix “Docker no space left on device”
You have to log in via sudo user and open the command line terminal by checking it in your operating system’s application area or using the “Ctrl+Alt+T” shortcut key. Once opened, follow all these methods described in this article.
Method 1: Docker System Prune
The ‘docker system prune command is being used to eliminate or delete unutilized objects or data, including images, containers, volumes, and networks. These objects are not erased unless we consciously remove them; even so, in docker 17.06.1 or higher, we must require the ‘–volumes’ possibility to remove volumes. It eliminates both dangling and unreferenced images; however, only by default are dangling images removed. The ‘docker system prune’ can only be used with a client and daemon API version of 1.25 or higher. Now execute the listed command:
You have to provide your sudo user password for its successful execution. Upon execution, you will get the following warning, as shown in the attached image. You have to enter “y” to go on with the process. When we implement the ‘docker system prune command, it sends an API request to the Docker daemon, which looks for all unused items on the host and eradicates them from the system. Since earlier versions of Docker removed all objects, including volumes, the ‘–volumes’ option was added.
Method 2: Removing Dangling Images
The volume command in Docker can be used to accomplish this. Because this erases any directory or folder in /var/lib/docker/volumes that are not a volume, you must ensure that no important documents are saved there. When creating a Docker image, there are usually numerous layers of images. Layers that have no reference to any tagged picture are referred to as dangling images. Dangling images take up storage space but do nothing. To view a list of all volumes, use the command:
Use the following command to get a list of all dangling volumes:
You have to provide your sudo user password for its successful execution.
Method 3: Removing Orphaned Volumes
To get started, you will need to erase any orphaned volumes in Docker. Now to get rid of all orphaned volumes, execute the following command:
Conclusion:
In this guide, we have discussed a few methods to eliminate the “Docker no space left on device” error. Now, I believe you can easily tackle this at your end by following this tutorial.