Docker containers report 'no space left on device' after systemd tmpfiles cleaned /var/lib/docker metadata despite free disk space
Environment
Ubuntu 22.04 host, Docker Engine 20.10, /var/lib/docker on ext4 partition with ample free space (df -h shows 60% used), systemd-tmpfiles configured via /etc/tmpfiles.d/clean.conf to remove old files under /var/tmp and /var/lib/docker/tmp older than 7 days; systemd-tmpfiles --clean runs via daily timer
Symptoms
Multiple containers start failing file writes with EROFS/ENOSPC 'no space left on device' while host shows significant free space; restarting docker daemon temporarily allows new containers but errors return after tmpfiles cleanup runs
Observations
docker info reports overlay2 driver and many lowerdir/upperdir entries. Running df -i shows inode exhaustion under /var/lib/docker despite overall free blocks. After manually removing orphaned tmpfiles and docker system prune, containers can write again. journalctl shows systemd-tmpfiles removing files under /var/lib/docker/tmp and occasionally removing metadata files used by overlay driver
Already attempted
Restarted docker daemon, ran docker system prune -a --volumes, modified tmpfiles config to exclude /var/lib/docker/tmp (but change applied after next scheduled run), temporarily moved tmpfiles cleanup cron to a different time (issue still reproduced when original cleanup executed)
Question
Did systemd tmpfiles removal of Docker temporary files corrupt overlay metadata or exhaust inodes, and how should tmpfiles be safely configured to avoid breaking Docker storage?
Verified community troubleshooting
Stop letting systemd-tmpfiles touch Docker's storage. Remove or change the tmpfiles.d rule that removes /var/lib/docker/tmp and instead run Docker-aware cleanup (docker system prune -a --volumes or a docker-gc job) on a safe schedule. To recover now: stop Docker (systemctl stop docker), check inode usage (df -i), run docker system prune after restart, and avoid running tmpfiles against /var/lib/docker in future. Verify by re-running the tmpfiles job manually—if no ENOSPC appears and containers can write, the config change succeeded. Roll back by restoring the original tmpfiles file if you need to re-enable broader cleanup.
Incident analysis
Most likely causes
Summary
Suggested Fixes
Continue troubleshooting
Related troubles
Matched from the title, description and tags
- Linux49% match
Linux reports 'No space left on device' while df -h shows plenty of free disk space — what is filling my filesystem?
Open1 answer - Cloud Computing39% match
Docker image pulls fail with 'no space left on device' though df shows plenty of disk — overlayfs inode exhaustion on Ubuntu 22.04
Open1 answer - Virtualization29% match
Docker container receives SIGKILL/exit 137 under sustained CPU load on cgroup v2 host despite ample host free memory
Open0 answers - Linux27% match
Docker containers lose DNS after host switched to systemd-resolved stub resolver on Ubuntu 22.04
Solved1 answer - Linux27% match
Ubuntu 22.04 laptop: Docker containers lose DNS resolution after suspend/resume (systemd-resolved stub resolver conflict)
Open0 answers