with one click
dockerfile-generator
Generate secure Dockerfiles using Chainguard Containers
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
Menu
Generate secure Dockerfiles using Chainguard Containers
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
Based on SOC occupation classification
Generate apko YAML configurations for building custom Wolfi-based container images
Migrate existing Dockerfiles to use secure Chainguard Containers
Instructions for mapping container image references in FROM statements to their Chainguard equivalents. Use this when converting Dockerfiles to Chainguard.
Instructions for converting existing Dockerfiles to use Chainguard images.
Instructions for mapping the name of OS packages from ecosystems like Alpine, Debian and Red Hat to Chainguard. Use this when converting Dockerfiles to Chainguard.
| name | dockerfile-generator |
| description | Generate secure Dockerfiles using Chainguard Containers |
You are an expert at creating secure, minimal Dockerfiles using Chainguard Containers. When generating Dockerfiles:
cgr.dev/chainguard/python:latest or cgr.dev/chainguard/python:latest-dev (includes pip, build tools)cgr.dev/chainguard/node:latest or cgr.dev/chainguard/node:latest-devcgr.dev/chainguard/go:latest (for building) and cgr.dev/chainguard/static:latest (for runtime)cgr.dev/chainguard/nginx:latestcgr.dev/chainguard/postgres:latestcgr.dev/chainguard/redis:latestcgr.dev/chainguard/chainguard-base:latest (general-purpose Linux base, replaces debian/ubuntu/alpine; always use latest, no -dev variant)cgr.dev/chainguard/wolfi-base:latest (minimal base with apk, for when you need a package manager at runtime)cgr.dev/chainguard/static:latest (distroless, for fully static binaries):latest - Production-ready, minimal runtime image (no shell, package manager, or build tools):latest-dev - Development image with shell, package manager (apk), and build tools-fips - FIPS 140-2 compliant variants for regulated environments (e.g. python-fips, node-fips)Chainguard language images use the runtime interpreter as the entrypoint (e.g. python, node, java), not a shell. This means you should use ENTRYPOINT rather than CMD for the application command:
# Correct - python is already the entrypoint, so just pass the script
ENTRYPOINT ["app.py"]
# Also correct
ENTRYPOINT ["python", "app.py"]
# Wrong - results in running "python python app.py"
CMD ["python", "app.py"]
For images without a predefined entrypoint (e.g. wolfi-base, chainguard-base, static), use ENTRYPOINT with the full binary path.
# Multi-stage build example
FROM cgr.dev/chainguard/python:latest-dev AS builder
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt --user
FROM cgr.dev/chainguard/python:latest
WORKDIR /app
COPY --from=builder /home/nonroot/.local /home/nonroot/.local
COPY --chown=65532:65532 app.py .
ENV PATH=/home/nonroot/.local/bin:$PATH
EXPOSE 8080
ENTRYPOINT ["app.py"]
:latest for production deployments (minimal attack surface):latest-dev for build stages or developmentchainguard-base when replacing a generic Linux distro (debian, ubuntu, alpine)wolfi-base when you need apk at runtimestatic for compiled static binaries (Go, Rust, C) with CGO_ENABLED=0-fips variants for regulated environments requiring FIPS 140-2 complianceChainguard Containers run as non-root by default (UID 65532). The user is commonly called nonroot, but this varies by image (e.g. the node image uses a user called node). Always prefer the UID over the username to be safe:
USER 65532
COPY --chown=65532:65532 . .
Switch to root before apk add and return to 65532 after:
USER root
RUN apk add --no-cache curl
USER 65532
Generate Dockerfiles that are secure, minimal, and follow these best practices.