What’s wrong with this Dockerfile?
Viktor loves to ask this question in interviews, even though it’s connected to Kubernetes at a high level and is a little bit outside the scope of this book. Let’s review it. This question tests your attention to detail and understanding of writing optimized and efficient Dockerfiles, even when the file appears error-free. Interviewers want to see how well you can identify improvements and suggest best practices rather than simply pointing out obvious errors.
Possible incorrect answer
“There’s nothing wrong with this Dockerfile; it looks fine.” Although this might be factually true, it shows a lack of understanding of Dockerfile best practices and optimizations, which are critical in production Kubernetes environments.
Correct approach
Here’s how to handle this:
- Start by reviewing the Dockerfile: Explain that “Even if there are no errors, Dockerfiles can often be optimized...