docker-compose INTERNAL ERROR cannot create temporary directory
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
The error INTERNAL ERROR: cannot create temporary directory from docker-compose means the system cannot create files in the temporary directory (typically /tmp on Linux or the path specified by the TMPDIR environment variable). This usually indicates a disk space issue, permission problem, or filesystem being mounted as read-only.
The Error
The full error message typically appears as:
This can occur when running any docker-compose command (up, build, pull, etc.).
Common Causes and Fixes
1. Disk Full (Most Common)
The /tmp directory or the filesystem it resides on is out of space:
Fix by freeing space:
2. Permission Issues
Your user does not have write permission to the temp directory:
3. /tmp Mounted as Read-Only
On some systems or containers, /tmp may be mounted read-only:
If read-only, remount or set a different temp directory:
4. noexec Flag on /tmp
Some security-hardened systems mount /tmp with noexec, which can cause issues:
5. Docker Compose Running in a Restricted Container
If docker-compose itself is running inside a container (CI/CD pipelines), the container's /tmp may be restricted:
Or in a Dockerfile:
Changing the Temporary Directory
If you cannot fix /tmp, tell docker-compose to use a different location:
For a permanent fix, add to your shell profile:
CI/CD Pipeline Fix
This error is common in CI/CD environments where runners have limited disk space:
GitHub Actions
GitLab CI
Preventive Measures
Set up automatic cleanup of the temp directory to avoid this error recurring:
For Docker specifically:
Common Pitfalls
- Cleaning /tmp blindly: Other applications use
/tmptoo. Only remove files you can identify (docker-, pip-, etc.) rather than runningrm -rf /tmp/*which could break running processes. - Docker overlay2 growth: Docker's storage driver (overlay2) can fill the disk. Check
/var/lib/docker/overlay2size and prune unused images/containers. - Inode exhaustion: Even with free disk space, you can run out of inodes, preventing new file creation. Check with
df -i /tmp. - Snap-installed Docker: On Ubuntu, snap-installed Docker may have restricted /tmp access. Use the apt-installed version instead.
- SELinux / AppArmor: Security modules can deny write access to /tmp for Docker processes. Check
journalctl -xefor SELinux or AppArmor denials.
Summary
- This error almost always means the temp directory is full or not writable
- Check disk space first with
df -h /tmpanddf -h / - Free space with
docker system pruneand by clearing old temp files - Set
TMPDIRto an alternative directory if/tmpcannot be fixed - In CI/CD, add disk cleanup steps before docker-compose commands

