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.
More on Images, Layers & Storage Drivers
What is a Docker image made of?BeginnerWhat is a layer and when is one created?BeginnerWhat is a union filesystem / OverlayFS?IntermediateWhat is copy-on-write (CoW) in containers?IntermediateWhy does deleting a file in a later `RUN` not shrink the image?IntermediateWhat storage drivers does Docker support and which is default?Intermediate