no space left on device
DockerCRITICALCommonRuntimeHIGH confidence

Docker host or container is out of disk space

What this means

This error indicates that the Docker daemon or a container has run out of disk space. It can happen when pulling images, writing container logs, or when an application inside a container writes data to its filesystem, exhausting the available storage.

Why it happens
  1. 1The host's disk where Docker stores its data (e.g., /var/lib/docker) is full.
  2. 2An accumulation of dangling images, build cache, and stopped containers is consuming all available space.
  3. 3A container's logging driver is misconfigured, leading to massive log files.
  4. 4An application inside a container is writing large files to the container's writable layer, which has a limited size.
How to reproduce

The host machine's hard drive fills up, and you attempt to build a new Docker image.

trigger — this will error
trigger — this will error
# This command will fail if Docker has no space to store the new layers
docker build -t my-app .

expected output

ERROR: failed to solve: failed to register layer: write /var/lib/docker/image/.../layer.tar: no space left on device

Fix 1

Prune Unused Docker Objects

WHEN This is the safest and most common first step to reclaim space.

Prune Unused Docker Objects
# Remove all stopped containers, dangling images, and build cache
docker system prune -a --volumes

Why this works

This command is a built-in utility to safely clean up unused Docker resources, often reclaiming gigabytes of space.

Fix 2

Analyze and Clear Disk Usage

WHEN Pruning is not enough; you need to find what else is using space.

Analyze and Clear Disk Usage
# See a detailed breakdown of Docker's disk usage
docker system df

# On Linux, find the largest files/directories in the Docker root
du -sh /var/lib/docker/* | sort -rh

Why this works

These commands help you identify whether the space is being consumed by images, containers, volumes, or build cache, allowing for a more targeted cleanup.

What not to do

Manually delete files from /var/lib/docker.

This directory is managed by the Docker daemon. Deleting files directly can corrupt Docker's state, leading to data loss or a completely broken Docker installation. Always use 'docker' commands to manage resources.

Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev

← All Docker errors