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": [

    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.

Make your mark

Join the writer's program

Are you a developer and love writing and sharing your knowledge with the world? Join our guest writing program and get paid for writing amazing technical guides. We'll get them to the right readers that will appreciate them.

Write for us
Writer of the month
Marin Bezhanov
Marin is a software engineer and architect with a broad range of experience working...
Build on top of Better Stack

Write a script, app or project on top of Better Stack and share it with the world. Make a public repository and share it with us at our email.

or submit a pull request and help us build better products for everyone.

See the full list of amazing projects on github