Interview Prep/CI/CD/Metrics, Performance and Cost

How do you reduce Docker image size and why does it matter for CI/CD?

BeginnerProductionMetrics, Performance and Cost
Answer

Smaller images push, pull and scale faster, and have fewer vulnerabilities. Use multi-stage builds, slim/distroless bases, .dockerignore, combine and clean up in the same RUN layer, install without recommended packages and caches (apt-get install --no-install-recommends, pip install --no-cache-dir), and inspect with docker history or dive. A 1.2 GB image dropping to 150 MB noticeably shortens deploys during autoscaling events.

All CI/CD questions

More on Metrics, Performance and Cost