Dockerfile Generator
Get a sensible starting Dockerfile for Node.js, Python, Go, Java, PHP or a static site, with multi-stage builds and an optional non-root user.
How to make a Dockerfile
Pick your stack
Node.js, Python, Go, Java (Maven), PHP (Apache) or a static site on nginx.
Set the version and port
Leave the version blank for a sensible default.
Set the start command
The start file, or the build target for Go.
Choose security
Run as a non-root user to limit the damage if the app is compromised.
Save it
Copy it, or download it as Dockerfile.
Worked example
This is what Dockerfile Generator gives for its own sample values. Open the tool above and change anything to try your own.
- Stack
- Node.js
- Version (blank for a sensible default)
- Port
- 3000
- Start file, or build target for Go
- server.js
- Run as a non-root user
- Yes
Dockerfile
FROM node:22-alpine AS deps WORKDIR /app COPY package*.json ./ RUN npm ci --omit=dev FROM node:22-alpine WORKDIR /app ENV NODE_ENV=production COPY --from=deps /app/node_modules ./node_modules COPY . . USER node EXPOSE 3000 CMD ["node", "server.js"]
About Dockerfile Generator
Get a solid starting Dockerfile for Node.js, Python, Go, Java, PHP or a static site. They use multi-stage builds where it helps and can run as a non-root user, which limits the damage if the app is compromised.
FAQs
Will it work as it is?
It is a starting point. Check the file names, ports and build commands against your project.
Why a non-root user?
If someone breaks into the app, they get fewer powers inside the container.
What about .dockerignore?
Add one that lists node_modules, .git and env files, so they stay out of the image.