advancedTop 100 Interview Questions

What does `.dockerignore` do, and why does it matter for build performance?

It excludes specified files/directories from being sent to the Docker build context, which both speeds up the build (less data transferred to the daemon) and prevents accidentally copying sensitive files (like `.env` or `.git`) into an image via a broad COPY instruction.

Ready to master this question?

Generate a complete walkthrough — background, the full answer in plain language, a working code example explained line by line, a real-world scenario, common mistakes, and how this same question gets asked in different ways.

Sign in to generate a response

Next Step

Continue to Why might a production Dockerfile explicitly set a non-root USER?← Back to all Docker questions