Dockerfile Generator
Generate a Dockerfile from a form: pick a language, base image, ports, env vars, build and start commands, then copy or download the file. How it works
Use the Dockerfile Generator
1# syntax=docker/dockerfile:1.72# Generated by CalcChef Dockerfile Generator — YYYY-MM-DD3# Tip: add a .dockerignore with at least: node_modules, .git, .env, dist, build, target, __pycache__4 5FROM node:24-alpine6WORKDIR /app7 8COPY package*.json ./9RUN npm ci10 11COPY . .12RUN npm run build13 14# Run as non-root15RUN addgroup -S app && adduser -S app -G app -u 1001 \16 && chown -R app:app /app17USER app18 19# Listening ports20EXPOSE 300021 22CMD ["node", "server.js"]Estimated size: ≈ 50–180 MB (alpine)
About the Dockerfile Generator
The default settings give a Dockerfile for a Node.js app that starts with # syntax=docker/dockerfile:1.7, then FROM node:24-alpine, WORKDIR /app, COPY package*.json ./, RUN npm ci, COPY . ., RUN npm run build, a non-root user, EXPOSE 3000 and a CMD that runs node server.js. Node.js 24 is the long-term-support line that endoflife.date listed on 16 October 2026, with security fixes until 30 April 2028. Check the tag against that list again before you build, because support dates move on. The file is text only: nothing has been built or checked against Docker.
What each language preset starts with
| Language | Base image | Install command | Port | Multi-stage by default |
|---|---|---|---|---|
| Node.js | node:24-alpine | npm ci | 3000 | no |
| Python | python:3.12-slim | pip install --no-cache-dir -r requirements.txt | 5000 | no |
| Go | golang:1.27-alpine | go mod download | 8080 | yes |
| Java | eclipse-temurin:21-jre-alpine | mvn -B -e -DskipTests dependency:go-offline | 8080 | yes |
| .NET | mcr.microsoft.com/dotnet/aspnet:10.0 | dotnet restore | 8080 | yes |
| Ruby | ruby:3.3-alpine | bundle install --jobs 4 --retry 3 | 4567 | no |
| PHP | php:8.3-cli-alpine | composer install --no-dev --no-scripts --prefer-dist | 8000 | no |
| Rust | rust:1-slim | none | 8080 | yes |
| Static HTML | nginx:1.30-alpine | none | 80 | no |
Read from the generator's own language defaults. They are starting values for you to change, not recommendations, and the tags were checked on 16 October 2026 against endoflife.date and nginx.org: Node.js 24 (long-term support), Go 1.27, .NET 10 (long-term support) and nginx 1.30 (the stable line). Python 3.12, Ruby 3.3, PHP 8.3 and Java 21 were still supported and are unchanged. The start commands assume a layout: Python runs app.py, Ruby runs app.rb on Sinatra's port 4567, and PHP runs php artisan serve, which only exists in a Laravel project. Java builds in a Maven image (with multi-stage off, that image is the only stage), and the build copies the first jar in target/ that is not a sources, javadoc or tests jar to app.jar. Rust has no install step, because cargo needs the source as well as Cargo.toml, and its build copies target/release/app, so the binary must be named app. PHP copies the Composer binary and installs unzip, installs without running scripts before the source is copied, and dumps the optimized autoloader after it. Its start command listens on 0.0.0.0, because artisan serve listens only inside the container by default.
How to use this tool
- Pick a project preset or a language, then a base image from the list or your own image:tag. Check that the tag is still supported: the defaults were checked on 16 October 2026.
- Set the working directory, ports, environment variables, build arguments, and the install, build and start commands.
- Choose multi-stage and a non-root user if you want them. Read any warning above the file.
- Press Copy or Download, then build the image yourself to check it.
Frequently asked questions
- How do I write a Dockerfile for a Node.js app?
- Copy package.json and the lock file first and run npm ci, so Docker can reuse that layer when only source files change. Then copy the rest, run the build, set a non-root user, EXPOSE the port and start the app with CMD. The generator writes those lines in that order for Node.js, starting from FROM node:24-alpine; change the tag if your app targets another supported Node.js line.
- Why is the syntax line the first line?
- Docker reads a parser directive such as # syntax=docker/dockerfile:1.7 only at the top of the file. Once a comment, a blank line or an instruction has been read, a later directive is treated as an ordinary comment, so the generator puts it first.
- How does it write environment variables with spaces or a dollar sign?
- A value with a space, a quote or a backslash is wrapped in double quotes, so my value becomes ENV APP_MODE="my value". A dollar sign is escaped, because Docker expands $name in ENV values, so the text $5 stays $5. One variable is one line, and several use continuation lines with no continuation after the last.
- What is the difference between the exec and shell form of CMD?
- A start command written as a JSON array, such as ["node", "server.js"], becomes the exec form and runs the program directly. Any other text becomes the shell form, which the generator wraps in /bin/sh -c on Alpine images and bash -c on others. Docker recommends the exec form, because the shell form does not pass signals such as SIGTERM to the program.
- Does the Dockerfile run as root?
- By default it adds a user called app with UID 1001 and switches to it, for every language except static HTML. The nginx image starts as root and binds port 80, so non-root is off for it by default and can still be ticked. A user name keeps only letters, digits, dot, dash and underscore.
- Does the page check that the Dockerfile builds?
- No. It writes the file from your form and removes line breaks and control characters from every value, with a warning that lists what it removed. It does not run Docker, so build the image and read the output before you rely on the file.
Related Tools
View all toolsHTTP Headers Viewer
See the request headers an echo service (httpbin.org) receives from one fetch by this page, or by your own URL. Copy as cURL, fetch(), Python or .env.
Random Data Generator
Generate 1 to 1,000 fake people as JSON, CSV or a SQL INSERT: id, name, email, phone, address, age and active, each optional but id. Seeds repeat rows.
User Agent Parser
Paste a User-Agent string to read the browser, engine, OS and version, device type and model, CPU hints or the crawler it names, with notes on frozen values.
SQL Query Formatter
Format SQL for Standard SQL, PostgreSQL, MySQL, SQLite or SQL Server, with keywords kept, upper-cased or lower-cased and 2-space, 4-space or tab indents.
Subnet Mask Cheat Sheet
Subnet mask table for every IPv4 prefix from /0 to /32: dotted mask, wildcard, total and usable hosts, with /31 counted as 2 (RFC 3021) and /32 as 1.
IP Address Viewer
See the public IP address your connection uses, with the approximate city, region, country and provider from ipapi.co, or look up any IPv4 or IPv6 address.