Standard single-stage Dockerfiles bundle build toolchains (like GCC, npm devDependencies, Git, and package managers) directly into the final shipping artifact. This expands production container image sizes from 50MB to over 1.2GB, introduces dozens of unpatched CVE attack surfaces, and slows down Kubernetes pod startup times.
Key Dockerfile Anti-Patterns to Avoid
Running as Root (UID 0): Containers running without an explicit USER appuser directive execute as the host root user inside container namespaces, increasing container escape risk.
Busting Layer Cache with COPY . .: Copying application source files before package.json or requirements.txt causes Docker to re-download all dependencies on every code edit.
Uncleaned Package Manager Caches: Running apt-get install without rm -rf /var/lib/apt/lists/* leaves hundreds of megabytes of cached index files in the filesystem layer.