How To Fix “No Space Left On Device” In Docker

Running into a no space left on device error while using Docker can be frustrating — especially when your disk seems fine. This guide explains what causes it, and how to clean up Docker properly with a real example.

The Error

You might see something like this when building or running a container:

failed to copy files: write /var/lib/docker/tmp/...: no space left on device

Or:

no space left on device: unknown

Even worse — it happens during docker build or docker pull.

Why It Happens

Docker uses internal storage for:

  • Images
  • Containers (even stopped ones)
  • Volumes
  • Build cache
  • Layer diffs

Over time, these build up and consume:

  • Disk space (GBs of images)
  • Inodes (Linux file system metadata — even if disk space is left!)

How To Fix No Space Left On Device

    1. Run Docker System Prune

    Clean up unused containers, networks, and dangling images:

    docker system prune
    

    Prompted to confirm? Hit y.

    To clean everything, including volumes and build cache:

    docker system prune -a --volumes
    

    Warning: This removes all unused data, including volumes.

    2. Remove Dangling/Unused Images

    docker images -f dangling=true
    docker rmi $(docker images -f dangling=true -q)
    

    3. Remove Stopped Containers

    docker container prune
    

    4. Remove Unused Volumes

    docker volume prune
    

    Or list and remove specific ones:

    docker volume ls
    docker volume rm <volume_name>
    

    5. Clean Build Cache (BuildKit)

    If you’re using Docker BuildKit:

    docker builder prune
    

    Clean everything (including all caches):

    docker builder prune --all
    

    6. Check Disk Usage with Docker

    docker system df
    

    This shows:

    • Size of images
    • Size of containers
    • Local volumes
    • Build cache

    Example output:

    TYPE            TOTAL     ACTIVE    SIZE      RECLAIMABLE
    Images          18        10        1.281GB   551.7MB (43%)
    Containers      32        0         81.99MB   81.99MB (100%)
    Local Volumes   2         2         1.569kB   0B (0%)
    Build Cache     108       0         352.6MB   352.6MB
    
    On Windows (WSL 2)

    If you’re using Docker Desktop on Windows with WSL 2:

    1. Open PowerShell:

    wsl --list --verbose
    

    2. Check your distro (e.g., docker-desktop-data)

    3. Clean WSL disk space:

    wsl --shutdown
    

    Then reclaim disk space from:

    C:\Users\<YourName>\AppData\Local\Docker
    

    (Or use Disk Cleanup / Docker Desktop → Settings → Resources)

    Summary

    ActionDescription
    docker system pruneClean unused containers/images/networks
    docker builder pruneClear build cache (especially with BuildKit)
    docker volume pruneRemove orphaned volumes
    docker system dfShow disk usage breakdown
    Windows WSL: wsl --shutdownHelps reset disk space for Docker Desktop

    The “no space left on device” error often creeps up slowly but is quick to fix once you know where to look. With regular pruning and monitoring using docker system df, you can keep your system clean and Docker running smoothly.

    This is the end of the How To Fix “No Space Left On Device” In Docker.

    You can read more useful articles like Solving DNS Resolution Issues Inside Docker Containers.

    Follow us for the more helpful posts!

    We hope this is a useful post for you.

    5 2 votes
    Article Rating
    Aaron LX

    Aaron LX

    Aaron is a passionate writer, crazy about shopping, eCommerce and trends. Besides his outstanding research skills and a positive mind, Aaron eagerly shares his experience with the readers.

    Leave a Reply or put your Question here

    0 Comments
    Oldest
    Newest Most Voted
    Inline Feedbacks
    View all comments
    0
    Would love your thoughts, please comment.x
    ()
    x