Interview Prep/Docker/Images, Layers & Storage Drivers

How many layers can an image have?

AdvancedConceptImages, Layers & Storage Drivers
Answer

overlay2 supports up to 128 lower layers (a kernel mount limit, with workarounds in newer versions), so very long Dockerfiles can fail with "max depth exceeded". Practically you want fewer than 20-30 layers for faster pulls and mounts. Squashing or multi-stage builds reduce depth.

All Docker questions Roadmap: Docker & containers

More on Images, Layers & Storage Drivers