How to fix “no space left on device” error in Docker?

Better Stack Team
Updated on April 7, 2023

The "no space left on device" error in Docker typically occurs when the Docker host system runs out of disk space, either on the host filesystem or within the Docker storage driver. To fix this error, you can try the following steps:

  1. Remove unused Docker images, containers, and volumes using the docker system prune command. This command will remove all stopped containers, unused images, and orphaned volumes. Note that this will permanently delete any data stored in the volumes, so use this command with caution:

     
    docker system prune -a
    
  2. Check the disk usage of the Docker storage driver using the docker system df command. This command will display the disk space usage for Docker images, containers, and volumes:

     
    docker system df
    

    If the disk usage is high, you can try removing unused Docker data using the "docker system prune" command as described above.

  3. Adjust the disk usage settings for the Docker storage driver by configuring the storage-opt option in the Docker daemon configuration file. This option allows you to specify the maximum size of the Docker data space, as well as the maximum size of the Docker metadata space. For example, to set the maximum size of the Docker data space to 10GB and the maximum size of the Docker metadata space to 1GB, you can add the following lines to the Docker daemon configuration file:

     
    {
      "storage-driver": "overlay2",
      "storage-opts": [
        "overlay2.override_kernel_check=true",
        "overlay2.size=10GB",
        "metadata-size=1GB"
      ]
    }
    

    Note that the exact location of the Docker daemon configuration file may vary depending on your operating system and installation method. Once you have made changes to the configuration file, you will need to restart the Docker daemon for the changes to take effect.

  4. If the above steps do not resolve the issue, you may need to resize the underlying filesystem of the Docker host. This can be done using standard Linux filesystem resizing tools, such as resize2fs for ext4 filesystems or xfs_growfs for XFS filesystems. However, this should only be done by experienced system administrators, as it can be risky and may result in data loss if not done correctly.

Got an article suggestion? Let us know
Explore more
Licensed under CC-BY-NC-SA

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

We are hiring.

Software is our way of making the world a tiny bit better. We build tools for the makers of tomorrow.

Explore all positions →

Reliability is the
ultimate feature

Delightful observability tools that turn your logs & monitoring into a secret weapon for shipping better software faster.

Explore Better Stack