How to fix failed to register layer: Error processing tar file(exit status 1): no space left on device in Docker

DockerBEGINNERHIGHUpdated Dec 6, 2025ยท 163 views

Docker has run out of disk space for images, containers, or volumes. Clean up unused Docker resources with docker system prune or expand your disk storage.

Quick fix

Fixes ENOSPC

docker system df
  1. Check Docker disk usage
  2. Remove unused containers, networks, and images
  3. Remove specific unused images
  4. Clean up build cache
docker โ€” error
docker system df
failed to register layer: Error processing tar file(exit status 1): no space left on device

What this error means

This error indicates that Docker cannot write data because the disk partition where Docker stores its data is full. Docker stores images, containers, volumes, and build cache in a data directory (typically `/var/lib/docker` on Linux). Over time, unused images, stopped containers, and dangling volumes accumulate and consume significant disk space. This is especially common in CI/CD environments or development machines where many images are pulled and built.

Typical symptoms

  • docker pull fails when downloading image layers
  • docker build fails during COPY or RUN instructions
  • Container creation fails with space-related errors
  • docker run fails immediately after starting
  • Build cache operations fail unexpectedly

Common causes

  1. Accumulated unused Docker images consuming disk space
  2. Stopped containers not removed (each keeps a writable layer)
  3. Dangling volumes from deleted containers
  4. Large build cache from repeated docker build operations
  5. Docker data directory on a small partition
  6. Log files from containers growing unbounded
  7. Underlying filesystem is genuinely full (not just Docker)

How to fix "failed to register layer: Error processing tar file(exit status 1): no space left on device"

1Check Docker disk usage

First, see how much space Docker is using:

bash
docker system df

This shows space used by images, containers, volumes, and build cache. The "RECLAIMABLE" column shows how much can be freed.

2Remove unused containers, networks, and images

Clean up all unused Docker resources:

bash
# Remove stopped containers, unused networks, dangling images
docker system prune

# Include unused volumes (careful - data loss possible)
docker system prune --volumes

# Remove ALL unused images, not just dangling ones
docker system prune -a

Warning: --volumes removes volumes not attached to containers. Ensure you don't need that data.

3Remove specific unused images

If you want more control, remove images selectively:

bash
# List all images with sizes
docker images -a

# Remove specific image
docker rmi <image_id>

# Remove all dangling images
docker image prune

# Remove images older than 24 hours
docker image prune -a --filter "until=24h"
4Clean up build cache

Build cache can grow very large with repeated builds:

bash
# Remove all build cache
docker builder prune

# Remove build cache older than 24 hours
docker builder prune --filter "until=24h"

# See build cache usage
docker system df --verbose
5Check host disk space

Verify the underlying disk has space:

bash
df -h /var/lib/docker

If the partition is nearly full even after Docker cleanup, you may need to expand the disk or move Docker's data directory.

6Move Docker data directory (if needed)

If /var/lib/docker is on a small root partition, move it:

bash
# Stop Docker
sudo systemctl stop docker

# Edit Docker daemon config
sudo nano /etc/docker/daemon.json

Add:

json
{
  "data-root": "/path/to/new/docker-data"
}

Then move the data and restart:

bash
sudo mv /var/lib/docker /path/to/new/docker-data
sudo systemctl start docker

Advanced notes

Container Log Limits: Container logs can grow unbounded. Set limits in daemon.json:

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

Automated Cleanup: Consider running docker system prune -f in a daily cron job on CI/CD runners.

Docker Desktop: On macOS/Windows, Docker Desktop uses a virtual disk that can be resized in Settings โ†’ Resources โ†’ Disk image size.

Frequently asked questions

What does "ENOSPC" mean?
This error indicates that Docker cannot write data because the disk partition where Docker stores its data is full. Docker stores images, containers, volumes, and build cache in a data directory (typically /var/lib/docker on Linux). Over time, unused images, stopped containers, and dangling volumes accumulate and consume significant disk space.
How do I fix "ENOSPC"?
Docker has run out of disk space for images, containers, or volumes. Clean up unused Docker resources with docker system prune or expand your disk storage.
What causes "ENOSPC"?
Accumulated unused Docker images consuming disk space Stopped containers not removed (each keeps a writable layer) Dangling volumes from deleted containers
Is the "ENOSPC" error serious?
Yes. This is a high-severity error that usually blocks work until it is fixed, but the steps above resolve it.

Official resources & further reading