max depth exceeded Docker Origin: Platform & cloud OSI layer 7 · Application Last updated 13 Oct 2026

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.

Exact message you may see max depth exceededtoo many layers
Seen on: Docker

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

  1. Combine RUN steps with &&
  2. Use multi-stage builds and copy only the result
  3. Flatten: docker export | docker import

Detailed fix by platform

Dockerfile

  1. RUN apt-get update && apt-get install -y a b c && rm -rf /var/lib/apt/lists/*

How to diagnose

  1. Layers — docker history --no-trunc image | wc -l
  2. 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:

Where this error sits

Origin: Platform & cloud. Errors that are often confused with or caused by this one (click to open):

1011 — Cloudflare Error 1011: Access denied (Hotlinking denied) (Cloudflare)1011cgo: C compiler gcc not found — Go: cgo: C compiler "gcc" not found: exec: "gcc": executable file not found in $PATH (Go)cgo: C compiler gcc n…Cloud Functions: Build failed — Cloud Functions: Build failed: function.js does not exist / npm install failed with exit code 1 (Cloud Build step) (Google Cloud / Firebase)Cloud Functions: Buil…conflict: unable to remove repository reference — conflict: unable to remove repository reference (must force) - container is using its referenced image (Docker)conflict: unable to r…COPY failed — COPY failed: file not found in build context / "/app/x": not found (Docker)COPY faileddid not complete successfully — failed to solve: process "/bin/sh -c ..." did not complete successfully: exit code: 1 (Docker)did not complete succ…ENOSPC — no space left on device (Docker / Linux) (Docker)ENOSPCexec format error — exec /usr/local/bin/docker-entrypoint.sh: exec format error (Docker)exec format errormax depth…

Explore the map of this error Full error map →

🧠 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.