The Dockerfile Generator
What this screen is for
The form that produces the Dockerfile: base image, working directory, dependency and build steps, exposed ports, and the command the container runs.
Before you start
| To do this | You need |
|---|---|
| Use the generator | the local-env Dockerfile read permission |
Opening it
Build βΊ Image Builder, or open a template from Tools βΊ Templates Library.
The Dockerfile Generator provides complete control over Dockerfile creation through an intuitive form interface with live preview. Whether you start from scratch or from a template, you can customize every aspect.
πΈ Screenshot Placeholder: The generator with a completed form and its output. Mark: (1) the base image, (2) the dependency steps, (3) the build steps, (4) the run command, (5) the generated Dockerfile.
Interface Layout
The interface is split into two panels:
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β β β
β Configuration Form β Dockerfile Preview β
β β β
β - Base Image β FROM node:20 β
β - Environment Vars β WORKDIR /app β
β - Labels β COPY package.json ./ β
β - Working Directory β RUN npm install β
β - Files β EXPOSE 3000 β
β - Run Commands β CMD ["npm", "start"] β
β - User β β
β - Args β β
β - Volume β β
β - Port β β
β - Entrypoint β β
β - CMD β β
β β β
β [Validate Dockerfile] β β
ββββββββββββββββββββββββββββββββββββββ΄ββββββββββββββββββββββββββββββββ
Configuration Options
Each form section maps to a Dockerfile directive:
| Section | Directive | Required | Description |
|---|---|---|---|
| Base Image | FROM |
Yes | The parent image for your container |
| Environment Variables | ENV |
No | Set environment variables in the container |
| Labels | LABEL |
No | Add metadata to your image |
| Working Directory | WORKDIR |
No | Set the working directory for subsequent instructions |
| Files | COPY |
No | Copy files from host to container |
| Run Commands | RUN |
No | Execute commands during image build |
| User | USER |
No | Set the user for running the container |
| Arguments | ARG |
No | Define build-time variables |
| Volume | VOLUME |
No | Create a mount point for external volumes |
| Port | EXPOSE |
No | Expose container ports |
| Entrypoint | ENTRYPOINT |
No | Configure container entry point |
| CMD | CMD |
No | Default command to run when container starts |
Creating a Dockerfile
Base Image
Enter the parent image (e.g., node:20, python:3.11-slim, golang:1.21). Use specific version tags instead of latest for reproducible builds. Consider slim/alpine variants for smaller images.
Environment Variables
Add key-value pairs via the β+ Add Environment Variableβ button (e.g., NODE_ENV = production).
Labels
Add metadata key-value pairs via β+ Add Labelβ (e.g., maintainer = team@example.com).
Working Directory
Set the directory where subsequent commands execute (e.g., /app).
Files (COPY)
Add file copy instructions via β+ Add Fileβ:
| Field | Description | Example |
|---|---|---|
| Host Path | Source path in your build context | package.json |
| Container Path | Destination path in the container | ./ |
| Option | Optional COPY flags | --chown=1000 |
Tip: Copy dependency files first (package.json), then source code (.), to leverage Docker layer caching.
Run Commands
Add build-time commands via β+ Add Run Commandβ (e.g., npm install). Chain related commands with && to reduce layers. Clean up temporary files in the same RUN instruction.
Remaining Options
| Field | Notes | Example |
|---|---|---|
| Args | Build-time variables | VERSION=1.0.0 |
| User | Run as non-root for security | node, 1000 |
| Volume | Persistent data mount point | /data |
| Port | Port your application listens on | 3000 |
| Entrypoint | Container entry point (JSON array format) | "node", "server.js" |
| CMD | Default command (JSON array format) | "npm", "start" |
Live Preview Panel
The right panel updates in real-time as you fill out the form.
Reordering Instructions
Drag and drop to reorder instructions for better layer caching. Reorderable directives: LABEL, WORKDIR, USER, RUN, COPY. The FROM instruction must always remain first.
Tip: Complete all form inputs first, then reorder if needed.
Validating and Scanning
- Review your Dockerfile in the preview panel
- Click βValidate Dockerfileβ
- A GitHub Actions workflow builds the image and scans it with Trivy
Scan Results
| Status | Meaning |
|---|---|
| Validated | No critical vulnerabilities, safe to use |
| Not Validated | Vulnerabilities found that may need attention |
| Scan Failed | Scan could not complete (check configuration) |
Available actions: Download Dockerfile, View Detailed Report, Cancel Scan.
Downloading Your Dockerfile
After validation, click βDownload Dockerfileβ in the results dialog. The file downloads as Dockerfile.
Scenario
Getting an image that starts, then getting one that is small.
- Set the base image first. Everything downstream β available package manager, shell, library versions β follows from it, and changing it later invalidates most of what you filled in.
- Fill the dependency and build steps in the order they must run. The generator writes them in the order you give; it does not reason about caching for you.
- Set the exposed ports to match what the application actually listens on, not what you intend it to listen on later.
- Generate and build locally. This is the first point at which anything is verified β the form does not compile.
- Once it starts, revisit layer order. Dependencies before source is what makes rebuilds fast, and it is the single change with the biggest effect.
- Scan it β see Security Scanning.
When it doesnβt work
| Symptom | Cause | How to check | Fix |
|---|---|---|---|
| The build fails on a missing package | The base image lacks it | The base image | Add an install step, or choose a fuller base |
| Rebuilds are slow | Source is copied before dependencies | The step order | Put dependency steps first |
| The container starts and exits | The run command is wrong or not long-running | The command field | Point it at the process that stays up |
| The port is open but nothing answers | The exposed port differs from what the app binds | The application config | Make them match |
Next
- Security Scanning β before it reaches an environment