Skip to content

How to Fix Docker Disk Space Full Error

DodaTech Updated 2026-06-24 2 min read

In this tutorial, you'll learn about How to Fix Docker Disk Space Full Error. We cover key concepts, practical examples, and best practices.

You get no space left on device when pulling images or running containers — Docker has filled your disk with unused layers, stopped containers, and dangling volumes.

The Problem

Error response from daemon: write /var/lib/docker/overlay2/xxx: no space left on device

Or:

docker: failed to register layer: Error processing tar file(exit status 1):
there might be not enough disk space: write /var/lib/docker/overlay2/...: no space left on device.

Step-by-Step Fix

Step 1: Check Docker disk usage

docker system df

Expected:

TYPE                TOTAL     ACTIVE    SIZE      RECLAIMABLE
Images              10        3         5.2GB     3.1GB (59%)
Containers          15        2         4.5GB     4.4GB (97%)
Local Volumes       8         1         1.2GB     1.1GB (91%)
Build Cache         0         0         0B        0B

Step 2: Prune unused objects

docker system prune -a --volumes

This removes all stopped containers, unused images, networks, build cache, and volumes.

Step 3: Remove specific large resources

List largest images:

docker images --format "{{.Repository}}:{{.Tag}} {{.Size}}" | sort -k2 -h -r | head -10

Remove specific image:

docker image rm <image-id>

Step 4: Clean build cache

docker builder prune -a

Step 5: Move Docker data directory

If disk is full at /var/lib/docker, move it to a larger partition:

sudo systemctl stop docker
sudo mv /var/lib/docker /mnt/large-disk/docker
sudo ln -s /mnt/large-disk/docker /var/lib/docker
sudo systemctl start docker

Step 6: Check overlay2 directory size

sudo du -sh /var/lib/docker/overlay2

If overlay2 is large, inspect per-image storage:

docker system df -v | grep -E "Images|Size|Reclaimable"

Step 7: Set up log rotation for containers

Prevent future disk issues with global log limits in /etc/docker/daemon.json:

{
  "log-driver": "json-file",
  "log-opts": {
    "max-size": "10m",
    "max-file": "3"
  }
}

Restart Docker after changes.

Step 8: Verify freed space

docker system df

The reclaimable column should show 0B after a full prune.

Prevention Tips

  • Run docker system prune weekly via cron
  • Set up log rotation for containers
  • Use --log-opt max-size=10m --log-opt max-file=3 on containers
  • Monitor disk usage with docker system df in CI
  • Use smaller base images (alpine, distroless)

Common Mistakes with disk space

  1. Overlapping type class instances that cause GHC to reject the program with ambiguous dispatch errors
  2. Non-exhaustive pattern matches that compile with warnings then crash at runtime
  3. Misunderstanding that String is [Char] with poor performance for large text operations

These mistakes appear frequently in real-world DOCKER code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.

Practice Exercise

Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.

This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.

FAQ

### What does `docker system prune -a` remove?

It removes all stopped containers, unused networks, dangling images, and unreferenced images. Adding --volumes also removes unused volumes. Running containers and used images are kept.

How do I find which container is using the most disk?

Use docker ps --size to see container sizes. For detailed disk breakdown, run docker system df -v which shows per-image and per-container usage.

Can I limit Docker's disk usage globally?

Yes, set "storage-opts": ["dm.basesize=20G"] in /etc/docker/daemon.json for devicemapper, or use --storage-opt size=20G per container. For overlay2, use docker run --storage-opt size=10G.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro