When to use it

Use this prompt when an image takes too long to build, is far larger than the application should need, or is about to go into production for the first time. It is also a good habit for any Dockerfile copied from a tutorial, since tutorials usually optimize for brevity rather than safety.

Typical symptoms that justify a review are images measured in gigabytes for a small web service, CI pipelines that reinstall every dependency after a one-line code change, and security scanners reporting hundreds of vulnerabilities from an old base image. The prompt does not replace a vulnerability scanner, but it explains the structural causes behind those reports and how to fix them in the Dockerfile itself.

How to customize it

  • [APPLICATION] helps the model choose a suitable base image and know which files are build-only.
  • [WHERE IT RUNS] changes the advice on health checks, signals and logging.
  • [PRIORITIES] settle trade-offs; the smallest possible base image can make debugging harder.
  • [CONSTRAINTS] stop the model from suggesting changes your organization cannot accept.
  • [.DOCKERIGNORE] is often where the real size problem hides, such as a copied node_modules or .git folder.

Why it works

The checklist in step 2 names the problems that appear in most real Dockerfiles, so the review does not depend on the model remembering them. The findings table makes each change traceable to a reason, which helps when you need to justify it in a pull request.

Asking for build and size-comparison commands turns the advice into something you can measure. The final step about unverifiable items keeps the model honest about what it cannot see, such as whether a dependency really needs native compilation.

Tips and variations

  • Build both versions and run your tests before replacing the old image.
  • Ask for a matching docker-compose.yml review if you use Compose locally.
  • Add “Explain like I am new to Docker” if you are learning.
  • For broader security thinking, try our lightweight threat model prompt.
  • Never paste real secrets into the prompt; replace them with placeholders first.