Most Dockerfile mistakes don't fail your build. They fail at 2 a.m., in production, when the image you shipped turns out to be running as root, pulling :latest that moved overnight, or running an installer you never verified.
Here's how to catch them before the build β the seven checks I run, with a real example.
The example: a Dockerfile with everything wrong
This is a small, realistic Dockerfile. It builds fine. Every line below is a problem:
FROM ubuntu RUN apt-get update RUN apt-get install -y curl ADD . /app RUN curl https://example.com/install.sh | sh FROM node:latest
Enter fullscreen mode
Exit fullscreen mode
The 7 checks
1. Unpinned base image. FROM ubuntu has no tag, so it silently resolves to latest . Pin it: ubuntu:22.04 , or a digest if you want it to never move.
2. :latest tag. FROM node:latest moves over time. The image you tested last month is not the image you build today.
3. Download-to-shell (critical). curl ... | sh pipes a remote script straight into a shell.β¦