This error occurs when Docker cannot extract and register image layers due to insufficient disk space on the host filesystem. The solution involves cleaning up unused Docker resources or expanding available storage.
The "failed to register layer: Error processing tar file(exit status 1): no space left on device" error indicates that Docker has exhausted the available disk space while attempting to extract and register a new image layer. Docker stores all its data, including images, containers, volumes, and build cache, in a specific directory (typically /var/lib/docker on Linux or within a virtual disk on Docker Desktop for Mac/Windows). When you pull an image or build a container, Docker downloads compressed layers and then extracts them. This extraction process requires additional free space beyond the compressed size because Docker needs room to write the uncompressed data. If the filesystem runs out of space during this extraction, the operation fails with this specific error. Docker does not automatically clean up unused resources like stopped containers, dangling images, or orphaned volumes. Over time, these accumulate and can consume tens of gigabytes of disk space, especially in development environments where images are frequently rebuilt or pulled.
First, analyze how Docker is consuming disk space:
docker system dfThis displays space used by images, containers, volumes, and build cache. For detailed breakdown:
docker system df -vAlso verify your host system's available disk space:
df -hLook for the partition containing /var/lib/docker (or Docker Desktop's virtual disk).
Remove all stopped containers, unused networks, dangling images, and build cache with a single command:
docker system pruneFor a more aggressive cleanup that also removes ALL unused images (not just dangling ones):
docker system prune -aAdd -f to skip the confirmation prompt:
docker system prune -a -fWarning: The -a flag removes ALL images not currently used by running containers. You will need to re-pull or rebuild them later.
By default, docker system prune does NOT remove volumes to prevent accidental data loss. To remove unused volumes:
docker volume pruneOr include volumes in the system prune:
docker system prune --volumesWarning: This permanently deletes data stored in unused volumes. Ensure you have backups of any important data before running this command.
Docker's BuildKit cache can grow substantially with frequent builds. To clear it:
docker builder pruneTo remove ALL build cache entries (not just dangling ones):
docker builder prune -aThis is especially effective if you've been doing many iterative builds during development.
For more targeted cleanup when you want finer control:
Remove only stopped containers:
docker container pruneRemove only dangling images:
docker image pruneRemove ALL unused images:
docker image prune -aList and selectively remove images:
docker images
docker rmi <image_id_or_name>Remove unused networks:
docker network pruneContainer logs can consume significant space. To truncate logs for a specific container:
# Find the container ID
docker ps -a
# Truncate its log file (requires root/sudo)
sudo truncate -s 0 /var/lib/docker/containers/<container_id>/<container_id>-json.logTo prevent future log growth, configure log rotation in your Docker daemon config (/etc/docker/daemon.json):
{
"log-driver": "json-file",
"log-opts": {
"max-size": "10m",
"max-file": "3"
}
}Then restart Docker: sudo systemctl restart docker
Confirm that disk space has been recovered:
docker system df
df -hThen retry your original Docker command:
docker pull <image_name>
# or
docker build -t <tag> .The operation should now complete successfully.
Docker Desktop (Mac/Windows): If using Docker Desktop, you can increase the virtual disk size through Settings > Resources > Advanced > Disk image size (called "Disk usage limit" in newer versions). On macOS, the Docker.raw or Docker.qcow2 file in ~/Library/Containers/com.docker.docker/Data/vms/ stores all Docker data. Deleting this file and restarting Docker Desktop will reset Docker to a clean state, but you will lose all images, containers, and volumes.
Moving Docker's data directory: If your root partition is consistently low on space, relocate Docker's data to a larger partition by creating or editing /etc/docker/daemon.json:
{
"data-root": "/path/to/larger/partition/docker"
}Then stop Docker, move existing data, and restart:
sudo systemctl stop docker
sudo mv /var/lib/docker /path/to/larger/partition/docker
sudo systemctl start dockerLVM-based storage: If using LVM and your volume is too small, expand it:
# Extend the logical volume
sudo lvextend -l +100%FREE /dev/mapper/your-vg-your-lv
# Resize the filesystem
sudo resize2fs /dev/mapper/your-vg-your-lvInode exhaustion: In rare cases, you might have available disk space but no inodes. Check with df -ih. Each file uses one inode, and Docker's many small layer files can exhaust inodes on some filesystems.
Storage driver considerations: The overlay2 storage driver (default on modern systems) is efficient, but older systems using devicemapper may have a 10GB per-image limit by default. Check your storage driver with docker info | grep "Storage Driver".
CI/CD environments: In automated pipelines, add cleanup steps:
# Example for GitHub Actions
- name: Clean up Docker
run: docker system prune -af --volumesPrevention best practices:
- Run docker system prune weekly or after major development sessions
- Use specific image tags instead of latest to avoid accumulating old versions
- Always use --rm flag for temporary containers: docker run --rm ...
- Configure log rotation to prevent unbounded log growth
- Monitor /var/lib/docker disk usage with alerting in production environments
unable to configure the Docker daemon with file /etc/docker/daemon.json
How to fix 'unable to configure the Docker daemon with file daemon.json' in Docker
docker: Error response from daemon: OCI runtime create failed: container_linux.go: starting container process caused: exec: "/docker-entrypoint.sh": stat /docker-entrypoint.sh: no such file or directory
How to fix 'exec: entrypoint.sh: no such file or directory' in Docker
image operating system "linux" cannot be used on this platform
How to fix 'image operating system linux cannot be used on this platform' in Docker
dockerfile parse error line 5: unknown instruction: RRUN
How to fix 'unknown instruction' Dockerfile parse error in Docker
manifest unknown: manifest unknown
How to fix 'manifest unknown' in Docker