What is a Dockerfile?
⚡
Quick Answer
A Dockerfile is a text script of instructions (FROM, RUN, COPY, CMD, etc.) that Docker executes to build a container image reproducibly.
Detailed Answer
Each instruction creates a cached layer, so ordering matters for build speed (put rarely changing steps first). Best practices include small base images, multi-stage builds to drop build tooling from the final image, a non-root USER, and pinning versions for reproducibility and security.
💡
Interview Tip
Bring up multi-stage builds and non-root user — concrete best practices signal real hands-on experience.
dockerdockerfileimages