← Back to all fixes
Docker image is several GB — much larger than expected
The Issue
`docker images` shows your app image is 2.5 GB. Pulls and deploys are slow.
Root Cause
Common causes: using a full OS base image instead of alpine, including dev dependencies, not cleaning up apt/apk cache, COPY-ing unnecessary files like node_modules or .git.
How to Fix
Switch base image to alpine variant: `FROM node:20-alpine` instead of `FROM node:20`Use multi-stage builds: build in one stage, copy only the output to a clean stageAdd `.dockerignore` to exclude `node_modules`, `.git`, `*.log`, `deploy/` etc.After apt-get install, always run: `rm -rf /var/lib/apt/lists/*` in the same RUN layerCheck what is bloating the image: `docker history myapp:latest`