This error occurs when Docker runs out of disk space while pulling images, building containers, or writing to volumes. The fix involves cleaning up unused Docker objects and ensuring adequate disk space.
The "no space left on device" error in Docker indicates that the filesystem where Docker stores its data has run out of free space. Docker uses disk space to store images, containers, volumes, build cache, and other data in the /var/lib/docker directory by default on Linux (or a virtual disk on Docker Desktop for Mac/Windows). When this directory fills up, Docker operations fail with this error. The specific message "failed to register layer: Error processing tar file(exit status 1)" indicates that Docker cannot extract and register a new image layer because there's no room to write the uncompressed data. Docker takes a conservative approach to cleanup and doesn't automatically remove unused objects like stopped containers, dangling images, or orphaned volumes. Over time, these accumulate and can consume significant disk space, especially in development environments with frequent builds.
First, see exactly how Docker is using disk space:
docker system dfThis shows space used by images, containers, volumes, and build cache. Add -v for verbose output:
docker system df -vAlso check your system's available disk space:
df -hRemove all stopped containers, unused networks, dangling images, and build cache:
docker system pruneFor a more aggressive cleanup that also removes unused images (not just dangling ones):
docker system prune -aWarning: The -a flag removes ALL images not used by running containers. You'll need to re-pull or rebuild them later.
Volumes are NOT removed by docker system prune by default to prevent data loss. To remove unused volumes:
docker volume pruneOr include volumes in the system prune:
docker system prune --volumesWarning: This permanently deletes data in unused volumes. Make sure you don't need any data before running this.
Docker's build cache can grow significantly with frequent builds. To clear it:
docker builder pruneTo remove all build cache (not just dangling entries):
docker builder prune -aFor more targeted cleanup:
Remove stopped containers:
docker container pruneRemove dangling images:
docker image pruneRemove all unused images:
docker image prune -aList and remove specific images:
docker images
docker rmi <image_id>Check that disk space was recovered:
docker system df
df -hThen retry your original Docker command (pull, build, etc.).
Docker Desktop (Mac/Windows): If you're using Docker Desktop, you can increase the disk space limit through Settings > Resources > Advanced > Disk image size. On Mac, the Docker.raw file stores all Docker data. Sometimes deleting it and restarting Docker Desktop can resolve persistent issues (but you'll lose all images, containers, and volumes).
Moving Docker's data directory: If your root partition is small, you can move Docker's data to a larger partition by editing /etc/docker/daemon.json:
{
"data-root": "/path/to/larger/partition/docker"
}Then restart Docker: sudo systemctl restart docker
LVM environments: If you're using LVM and the volume is too small, expand it:
lvextend -l 100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv
resize2fs /dev/mapper/ubuntu--vg-ubuntu--lvInode exhaustion: In rare cases, you might have disk space but no inodes. Check with df -ih. Each file uses one inode, and many small Docker layers can exhaust inodes.
Devicemapper storage driver (RHEL/CentOS): The devicemapper driver has a 10GB per-image limit by default. Large images may fail even with available disk space. Consider switching to overlay2.
Prevention best practices:
- Run docker system prune regularly (weekly or after major builds)
- Use specific image tags instead of latest to avoid accumulating old versions
- Add --rm flag when running temporary containers: docker run --rm ...
- Set up a cron job for automated cleanup in CI/CD 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