1. Home
  2. Developer
  3. Dockerfile Generator

Dockerfile Generator

Pick a language and options to get a Dockerfile that follows best practices.

For every format and option in one place, use Server Config Generators →

Runs in your browser · No upload
Dockerfile
FROM node:24-alpine AS deps WORKDIR /app ENV NODE_ENV=production COPY package.json package-lock.json ./ RUN npm ci --omit=dev && npm cache clean --force FROM node:24-alpine AS runtime WORKDIR /app ENV NODE_ENV=production COPY --from=deps --chown=node:node /app/node_modules ./node_modules COPY --chown=node:node . . USER node EXPOSE 3000 CMD ["node", "server.js"]
.dockerignore
.git .gitignore .env .env.* !.env.example Dockerfile .dockerignore docker-compose*.yml compose*.yaml *.md .vscode .idea .DS_Store node_modules npm-debug.log* coverage dist
Build and run commands
# Build the image docker build -t my-app . # Run the container docker run --rm -p 3000:3000 my-app
Review the generated Dockerfile before using it in production. Do not bake passwords or tokens into the image; pass them as environment variables or secrets at run time.

Your input is processed in this browser and never sent to a server.

How to use

  1. Pick a language or framework. Presets cover Node.js, Next.js, Python, Go, Java, Rust, .NET and static sites (nginx).
  2. Choose the base image version and app port, then fill in the fields that preset needs (package manager, start command, JAR path and so on).
  3. Turn best practices on or off with the multi-stage build, non-root user and HEALTHCHECK checkboxes.
  4. Copy or download the generated Dockerfile and .dockerignore. Build and run commands are shown too.

Options

Option What it does
Multi-stage build Keeps build tools and source out of the final image, which makes it smaller and shrinks the attack surface. Next.js and static sites are always multi-stage.
Non-root user Runs the container process as a user other than root. Node uses the built-in node user, others create an app user with UID 10001, and .NET uses USER $APP_UID.
HEALTHCHECK Calls the app port and path every 30 seconds and marks the container healthy or not. It only uses tools the image has (wget, python).
.dockerignore Keeps files such as .git, .env and node_modules out of the build context and the image. .env.example is kept as an exception.

What each preset produces

  • Node.js: node:<version>-alpine. With the build step on, it is split into install, build and a runtime stage that installs production dependencies only. Installs use the lock file: npm ci, pnpm install --frozen-lockfile or yarn install --frozen-lockfile.
  • Next.js: copies only the output: "standalone" result (.next/standalone, .next/static, public) and runs node server.js. Your next.config must enable standalone output.
  • Python: installs packages into a virtual environment at /opt/venv in the first stage and copies just that folder to the runtime stage. Flask and Django default to gunicorn, FastAPI to uvicorn; make sure the package is in requirements.txt.
  • Go: builds a static binary with CGO_ENABLED=0 and copies it to alpine. It copies go.sum* so the build still works when there is no go.sum.
  • Java: Maven copies pom.xml first so the dependency layer is cached, and the runtime image is eclipse-temurin:<version>-jre-alpine. Gradle runs bootJar, so check the JAR path yourself.
  • Rust: builds on rust:1-bookworm and runs on debian:bookworm-slim, the same Debian generation, because a glibc mismatch between builder and runtime breaks the binary.
  • Static site: puts your build output on nginx. With non-root on it uses nginxinc/nginx-unprivileged and port 8080; with it off, nginx:stable-alpine and port 80.

Example: multi-stage Node.js

With the build step on and the start command node dist/index.js, you get three stages: deps, build and runtime. The runtime stage installs production dependencies with npm ci --omit=dev, copies only the dist folder and switches to USER node.

Things to watch

  • Image tag versions are only the choices offered when this page was written. Check the support window of your language version and the real tags on Docker Hub, and pin a digest if you need reproducible builds.
  • Review the generated Dockerfile before putting it into production. Your app may need extra system packages, build arguments or a migration step.
  • Do not put passwords, API keys or tokens into the image with ENV or ARG; they stay in the image history. Pass them at run time as environment variables, secrets or volumes.
  • To run several services together, continue with the Docker Compose Generator, and for a reverse proxy in front use the Nginx Config Generator. Environment files can be tidied with the Env Converter, a host service can be written with the systemd Service Generator, and YAML can be checked with the JSON YAML Converter.

Frequently asked questions

Why use a multi-stage build?

Compilers, dev dependencies and source code are only needed to build. Copying just the result into the final image makes it smaller and leaves fewer tools for an attacker to use.

What changes when I run as a non-root user?

If the app is compromised inside the container, the attacker does not get root, so the damage is limited. Some environments such as Kubernetes do not let non-root processes bind ports below 1024, so a high port such as 3000 or 8080 is recommended.

Alpine or slim images?

This tool uses alpine for Node, Go and Java and slim (Debian) for Python, because some Python packages have no prebuilt wheels for alpine (musl) and can be slow or fail to install there.

What if my HEALTHCHECK keeps reporting unhealthy?

Check that the app answers with a non-error status on the path you set, and that it binds to 0.0.0.0 so 127.0.0.1 inside the container works. If the runtime image has no wget or curl, you have to install one.

Is my input sent to a server?

No. The Dockerfile is generated in your browser and goes nowhere.

Your input is processed in this browser and never sent to a server.

Can't find the tool you need?

Tell us what you want to do. We build the most requested tools first.