Error response from daemon: max depth exceeded (too many image layers)
The image has more layers than the storage driver allows (127 for overlay2), usually from repeatedly committing containers or very long Dockerfiles.
max depth exceededtoo many layers Meaning
Each RUN/COPY/ADD and each docker commit adds a layer. Images built by committing a container in a loop, or Dockerfiles with hundreds of steps, exceed the limit.
Common causes
- Image built via repeated docker commit
- Very many RUN/COPY instructions
- Base image already close to the limit
⚡ Quick fix
- Combine RUN steps with &&
- Use multi-stage builds and copy only the result
- Flatten: docker export | docker import
Detailed fix by platform
Dockerfile
RUN apt-get update && apt-get install -y a b c && rm -rf /var/lib/apt/lists/*
How to diagnose
- Layers — docker history --no-trunc image | wc -l
- Recent change — Did it start after a deploy, upgrade, or configuration change? Compare with the last working version.
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
- 1011 Cloudflare Error 1011: Access denied (Hotlinking denied)
- cgo: C compiler gcc not found Go: cgo: C compiler "gcc" not found: exec: "gcc": executable file not found in $PATH
- Cloud Functions: Build failed Cloud Functions: Build failed: function.js does not exist / npm install failed with exit code 1 (Cloud Build step)
Most viewed in Docker
- docker-credential-desktop error getting credentials - err: exec: "docker-credential-desktop": executable file not found in $PATH
- pull access denied pull access denied for image, repository does not exist or may require 'docker login'
- unauthorized: authentication required unauthorized: authentication required (docker push / pull)
Other ways to find it
Where this error sits
Origin: Platform & cloud. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 13 Oct 2026