How do you reduce an image's size?
BeginnerConceptImages, Layers & Storage Drivers
Answer
Use a smaller base, multi-stage builds, combine RUN cleanup in the same layer, --no-install-recommends, a good .dockerignore, install only runtime dependencies, strip binaries, and avoid copying build tools. Verify with docker images, docker history and dive.
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