Write a Dockerfile for your app

A ChatGPT prompt that writes a production-ready Dockerfile for your app, with multi-stage builds, small images and an explained line-by-line setup.

Published
Works with
ChatGPT, Claude and Gemini
Level
Intermediate
By
GoodAIPromt editorial team

A working Dockerfile is easy; a good one is small, secure and fast to rebuild. This prompt writes a Dockerfile for your stack using multi-stage builds, a non-root user and good layer caching, then explains each line and adds a .dockerignore and a docker-compose file for local development.

The prompt

You are a senior DevOps engineer. Write a Dockerfile for my application.

Language, framework and version: [STACK, e.g. Node 22 with Next.js, Python 3.12 with FastAPI]
How the app is built and started now: 
Dependencies file(s): [DEPENDENCY FILES, e.g. package.json]
Port and environment variables needed (names only, no secrets): 
Other services it needs locally: [SERVICES, e.g. Postgres, Redis, or "none"]
Target: [TARGET, e.g. development, production or both]

Provide:
1. A multi-stage Dockerfile with a slim base image, dependency caching, a non-root user and a healthcheck where it makes sense.
2. A .dockerignore file.
3. A docker-compose.yml for local development with the services above.
4. A line-by-line explanation of the Dockerfile.
5. Commands to build, run and check the image size.
6. Security notes: what never to bake into the image, and how to pass secrets at runtime.

0 of 2 blanks filled

How to use it

  1. Describe your real build and start commands so the container matches how the app runs today.
  2. Build and run it locally, then fix any error by pasting the output back in.
  3. Commit the files and use them in your CI pipeline.

Tips

Frequently asked questions

What does this prompt do?

A ChatGPT prompt that writes a production-ready Dockerfile for your app, with multi-stage builds, small images and an explained line-by-line setup.

Which AI tools does it work with?

It is written for ChatGPT, Claude and Gemini. It also works in other AI tools that accept text prompts, with small changes.

What do I need to fill in?

2 blanks: build and start commands; port and env vars. Click each blue blank on the page, type your details and press Copy prompt.

Is this prompt free to use?

Yes. You can copy and use it for personal and commercial work.

dockerdockerfiledevopscontainers

More prompts for ChatGPT, Claude, Gemini.