Dockerfile Generator
Generate production-ready Dockerfiles for Node.js, Python, Go, Java, and Rust. Supports multi-stage builds, non-root users, health checks, and popular package managers.
Language
Configuration
Dockerfile
When a Dockerfile generator is the right tool
Use this page to draft a Dockerfile for Node.js, Python, Go, Java, or Rust in the browser. Toggle a multi-stage build, a non-root user, and a HEALTHCHECK, then copy or download the file. Treat the output as a starting point: several defaults need a human pass before you build for production.
For a compose file around the image, see Docker Compose Formatter or Docker Run to Compose.
Use cases
Getting a Node or Python first draft
Node starts on 20-alpine, npm, port 3000, WORKDIR /app, with multi-stage, non-root, and HEALTHCHECK enabled, a build of npm run build, and a run command of node server.js. Change Run Command to the script path only. Yarn and pnpm switch the install lines (pnpm is installed with npm first; a lockfile is copied when present in the template).
Compiled languages
Go and Rust multi-stage runtimes are FROM scratch and expect a binary named app. Java builds with Maven on eclipse-temurin and, in multi-stage mode, copiestarget/*.jar into a JRE image. Single-stage Java expects target/app.jar.
How the file is generated
Each language has its own template. Health checks probe http://localhost:$PORT/health (Java uses /actuator/health) with wget or curl, except Go-on-scratch as noted above. Alpine images may have wget; Debian slim Python images often do not ship curl unless you install it.
FROM node:20-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build
FROM node:20-alpine AS runner
WORKDIR /app
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/package.json .
USER appuser
EXPOSE 3000
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \
CMD wget -qO- http://localhost:3000/health || exit 1
CMD ["node", "node server.js"]Edit Run Command to dist/index.js (or another path) so the CMD becomes CMD ["node", "dist/index.js"]. The default also assumes a dist directory in the runner stage.
What this tool does not do
It does not build or scan an image, pull live tags, write a .dockerignore, or guarantee a working HEALTHCHECK in slim or scratch images. Generation stays in your browser.
How to use Dockerfile Generator
- Pick a language and version, then adjust port, working directory, and package manager.
- Set build and run commands carefully — for Node and Python, put only the script path in Run Command.
- Review the Dockerfile, especially COPY paths and HEALTHCHECK, then Copy or Download it.
Frequently asked questions
How does Dockerfile Generator work?
Choose Node.js, Python, Go, Java, or Rust and adjust version, port, working directory, package manager (npm/yarn/pnpm or pip/poetry/uv), and optional build or run commands. Multi-stage build, non-root user, and HEALTHCHECK default to on for Node.js. The Dockerfile updates as you change options. Copy or Download (a file named Dockerfile) stays in your browser. This is a starter template, not a production-hardened image.
Why does the default Node file say CMD ["node", "node server.js"]?
The exec-form CMD already prefixes node (or python). The default Run Command is “node server.js” (and “python main.py” for Python), so the generator emits CMD ["node", "node server.js"] until you change Run Command to a script path only, such as server.js or dist/index.js. The same doubling happens for Python if you leave the default run line.
Do multi-stage, non-root, and HEALTHCHECK work the same for every language?
No. Some COPY --from paths are hardcoded to /app even if you change the working directory (Node multi-stage copies /app/node_modules, /app/dist, and /app/package.json; Java copies /app/target/*.jar). Java multi-stage emits USER before that COPY. Go and Rust multi-stage use a scratch runtime and assume a binary named app. Rust does not emit HEALTHCHECK even when the toggle is on. Go’s scratch healthcheck is CMD ["/app", "health"]. Python’s slim healthcheck calls curl, which the official slim image may not include. Poetry in a multi-stage Python build exports requirements.txt in the builder but does not install those dependencies before the runner copies site-packages, and that copy uses a wildcard path that Docker may not expand.
Which language versions are offered?
The menus are a fixed snapshot: Node 20/18/22/16, Python 3.12–3.9, Go 1.22–1.20, Java 21/17/11, and Rust 1.77–1.75. They are not loaded from Docker Hub. Switching language resets version, port, and the default build/run commands for that language, and leaves the three toggles as they were.
Related tools and guides
References
- See the Dockerfile reference for instruction semantics. Templates here are starting points — read them before you build.
- Official language images and tags change over time. The version list in this tool is not a live catalog.