# Instead of:FROMnode:20# ~1GB# Use:FROMnode:20-alpine # ~130MBFROMpython:3.12-slim # ~150MB vs 900MB for full
Note Alpine images use musl libc instead of glibc, which can cause issues with some native Node.js modules or Python C extensions. Test thoroughly. Debian slim is a safer middle ground if Alpine causes problems.
Note Common culprits: using the full Ubuntu/Debian base, leaving build tools installed, not cleaning apt/pip caches, copying node_modules into the image. Use docker history to identify the largest layers.
Frequently asked questions
How do you reduce size?
Docker covers this with 2 copy-ready snippets on this page. The "Use Small Base Images" snippet in Docker uses `FROM <image>:<version>-alpine`.
Which command does the Docker example use?
The "Use Small Base Images" snippet uses `FROM <image>:<version>-alpine`, from the Best Practices section of the Docker cheat sheet.
What other Docker snippets are shown for "reduce size"?
Besides "Use Small Base Images", this page also shows "Bloated Image Size".
Is there anything to watch out for?
Yes. For "Use Small Base Images": Alpine images use musl libc instead of glibc, which can cause issues with some native Node.js modules or Python C extensions. Test thoroughly. Debian slim is a safer middle ground if Alpine causes problems.