Skip to main content

Docker Image Size Analyzer

Paste your Dockerfile to get a layer-by-layer size estimate, optimization opportunities, and a suggested multi-stage build.

✓ Layer size breakdown ✓ Multi-stage build suggestion ✓ Security + .dockerignore tips

Layer Analysis

Paste a Dockerfile and click Analyze.

Base Image Size Comparison

Base Image Compressed Size Notes
scratch0 MBOnly for static binaries (Go/Rust)
gcr.io/distroless/base~2 MBNo shell, minimal attack surface
alpine:3~5 MBmusl libc, may break native modules
debian:bookworm-slim~30 MBGood compatibility, glibc
node:20-alpine~45 MBNode on Alpine
node:20-slim~80 MBNode on Debian slim
python:3.12-slim~70 MBPython on Debian slim
node:20~350 MBFull Debian, avoid in production
ubuntu:22.04~30 MBGreat compatibility but bulky
Share this tool: X / Twitter LinkedIn
✓ 60,000+ developers use DevPlaybook ★★★★★ 4.8 / 5 on Gumroad ✓ MIT licensed · Instant download ✓ No login required

Related Products

on Gumroad

You Might Also Need

More Free Tools

Enjoying this tool? Get more like it.

Weekly developer tool guides, productivity playbooks & AI tricks. Free. No spam.

DevPlaybook Pro 7 days free

Unlock AI-Powered Dev Tools

  • ⚡ AI Code Review, Doc Generator & SQL Builder
  • ⚡ All premium templates & early access
  • ⚡ Member discounts on Gumroad products
Start Free Trial →

$9/mo after trial · Cancel anytime

Want the full toolkit?

Get DevPlaybook Pro

Every template, guide, boilerplate, and automation script in one bundle. 13 premium products — grab them all at once and save big.

$79
$241 separately Save $162 (67% off)
Get DevPlaybook Pro — $79 →

MIT licensed · Instant download · No subscription

See what's included → Browse all deals →

Frequently Asked Questions

Why should I care about Docker image size?▼

Smaller images pull faster in CI/CD pipelines (critical for autoscaling), start containers faster in serverless/ephemeral environments, consume less storage in registries (reducing costs), and have a smaller attack surface — fewer packages mean fewer CVEs to patch. A 200 MB image pulls ~5× faster than a 1 GB image on a 100 Mbps connection.

What is a multi-stage build and when should I use it?▼

Multi-stage builds use multiple FROM statements. Stage 1: install build tools, compile your app. Stage 2 (final): copy only the compiled output into a minimal base image — no build tools, no source code. Use multi-stage builds whenever you have a compile step: Go, Rust, Java/Gradle, TypeScript, webpack bundles. The savings can be enormous: a Go app might go from 800 MB (golang:latest) to 15 MB (scratch).

What base image should I use?▼

scratch: zero-overhead, only for statically compiled binaries (Go, Rust). alpine: ~5 MB, uses musl libc — small but may have glibc compatibility issues. debian:slim / ubuntu:22.04-minimal: 50–80 MB, good compatibility. node:alpine vs node:slim: alpine is ~50 MB smaller but has native module compilation issues. For production, prefer distroless (gcr.io/distroless) for security without the shell.

How do I minimize apt-get layer size?▼

Always combine update, install, and clean in ONE RUN command: RUN apt-get update && apt-get install -y --no-install-recommends pkg1 pkg2 && rm -rf /var/lib/apt/lists/*. Split commands create separate layers where package lists remain in the image. The --no-install-recommends flag skips optional packages, often saving 50–200 MB.

What should be in .dockerignore?▼

Always include: node_modules/ (can be 500 MB+), .git/, *.log, .env, dist/, build/, coverage/, .DS_Store, *.test.ts, __tests__/. Not having a .dockerignore means COPY . . sends everything to the build context, which is slow and may include secrets.