From chainguard-codegen
Maps Dockerfile FROM statements to Chainguard container images using tag rules, dfc MCP server, organization namespaces, and lookup for unknowns. Use when converting Dockerfiles to Chainguard.
How this skill is triggered — by the user, by Claude, or both
Slash command
/chainguard-codegen:mapping-container-images-to-chainguardThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
When converting `FROM` statements in a Dockerfile to use Chainguard images, follow
When converting FROM statements in a Dockerfile to use Chainguard images, follow
these steps:
If the dfc MCP server is available, use it to perform automated conversion. It
handles registry rewriting, image name translation, and tag mapping automatically.
Use the convert_dockerfile tool to convert a full Dockerfile, or
analyze_dockerfile to inspect the current state before converting.
When using dfc, always pass the organization name if you know it. If you don't,
use ORG as a placeholder and remind the user to substitute their own.
Every Chainguard customer has their own organization namespace at cgr.dev:
cgr.dev/ORGANIZATION/image-name:tag
chainguardCheck ~/.claude/chainguard-preferences.md if it exists, or ask the user if the
organization name is unknown.
Follow these rules when converting tags from upstream images to Chainguard:
chainguard-base always uses latest — never add a version or -dev suffixlatest
FROM node → FROM cgr.dev/ORGANIZATION/node:latestFROM node:lts → FROM cgr.dev/ORGANIZATION/node:latestFROM node:14.17.3 → FROM cgr.dev/ORGANIZATION/node:14.17-dev suffix when the stage has RUN commands (except chainguard-base)
FROM node:14 (stage has RUN) → FROM cgr.dev/ORGANIZATION/node:14-devFROM node:14 (no RUN) → FROM cgr.dev/ORGANIZATION/node:14RUN commandsExamples:
FROM node:14 → FROM cgr.dev/ORG/node:14-dev (if stage has RUN commands)FROM node:14.17.3 → FROM cgr.dev/ORG/node:14.17-dev (if stage has RUN commands)FROM debian:bullseye → FROM cgr.dev/ORG/chainguard-base:latest (always)FROM golang:1.19-alpine → FROM cgr.dev/ORG/go:1.19-dev (if stage has RUN commands)| Upstream Image | Chainguard Image | Notes |
|---|---|---|
node, node:* | cgr.dev/ORGANIZATION/node | |
python:* | cgr.dev/ORGANIZATION/python | |
golang:*, go:* | cgr.dev/ORGANIZATION/go | Use static for distroless runtime |
golang:*-alpine | cgr.dev/ORGANIZATION/go | Strip the -alpine suffix |
openjdk:*, eclipse-temurin:*, amazoncorretto:* | cgr.dev/ORGANIZATION/jdk (build) or cgr.dev/ORGANIZATION/jre (runtime) | |
maven:* | cgr.dev/ORGANIZATION/maven | |
gradle:* | cgr.dev/ORGANIZATION/gradle | |
php:*-cli, php:* | cgr.dev/ORGANIZATION/php | |
php:*-fpm | cgr.dev/ORGANIZATION/php:latest-fpm | Pass custom mapping to dfc via --mapping |
nginx:* | cgr.dev/ORGANIZATION/nginx | |
ruby:* | cgr.dev/ORGANIZATION/ruby | |
rust:* | cgr.dev/ORGANIZATION/rust | |
debian:*, ubuntu:* | cgr.dev/ORGANIZATION/chainguard-base:latest | Always latest, no -dev variant |
alpine:* | cgr.dev/ORGANIZATION/chainguard-base:latest | Always latest, no -dev variant |
fedora:*, centos:*, ubi* | cgr.dev/ORGANIZATION/chainguard-base:latest | Always latest, no -dev variant |
scratch | cgr.dev/ORGANIZATION/static:latest | For fully static binaries |
gcr.io/distroless/static:* | cgr.dev/ORGANIZATION/static:latest | |
gcr.io/distroless/base:* | cgr.dev/ORGANIZATION/chainguard-base:latest | |
postgres:* | cgr.dev/ORGANIZATION/postgres | |
redis:* | cgr.dev/ORGANIZATION/redis | |
mysql:*, mariadb:* | cgr.dev/ORGANIZATION/mariadb | |
memcached:* | cgr.dev/ORGANIZATION/memcached |
For generic Linux distributions (debian, ubuntu, alpine, fedora, centos,
ubi*), use chainguard-base:
FROM cgr.dev/ORGANIZATION/chainguard-base:latest
latest taglatest-dev variant for chainguard-basechainguard-base provides apk for package installationFor compiled binaries (Go, Rust, C) with no external runtime dependencies:
# Build stage
FROM cgr.dev/ORGANIZATION/go:latest-dev AS builder
# ... build with CGO_ENABLED=0 for fully static ...
# Runtime stage
FROM cgr.dev/ORGANIZATION/static:latest
Note that CGO_ENABLED=0 is typically required for the static image. If the
binary links against glibc, check images.chainguard.dev for a suitable
dynamic runtime image.
If FIPS compliance is required (check ~/.claude/chainguard-preferences.md), append
-fips to the image name:
python → python-fipsnode → node-fipsgo → go-fipsjdk → jdk-fipschainguard-base → chainguard-base-fipsFor example: cgr.dev/ORGANIZATION/python-fips:latest-dev
If the original FROM uses a digest reference, the converted image should also
include a digest. The digest will naturally be different for the Chainguard image.
Example original:
FROM python:3.12-slim@sha256:a866731a6b71c4a194a845d86e06568725e430ed21821d0c52e4efb385cf6c6f
Should become something like:
FROM cgr.dev/ORGANIZATION/python:3.12-dev@sha256:<chainguard-digest>
To get the correct digest for the Chainguard image:
# With crane (prefer this if available)
crane digest cgr.dev/ORGANIZATION/python:3.12-dev
# Or with docker
docker pull cgr.dev/ORGANIZATION/python:3.12-dev
docker inspect --format='{{index .RepoDigests 0}}' cgr.dev/ORGANIZATION/python:3.12-dev
If you're unsure which Chainguard image to use, or need to verify an image exists
and check its documentation, use the ai-docs MCP server:
list_images() — see all available Chainguard imagesget_image_docs(image_name) — get documentation for a specific imagesearch_docs(query) — search by technology, use case, or keywordFor example, to find the right image for a Laravel PHP application:
get_image_docs("php")
search_docs("PHP FPM Chainguard")
You can also check the Chainguard Image Directory directly:
https://images.chainguard.dev/directory/image/<image-name>/overview
https://images.chainguard.dev/directory/image/<image-name>/versions
npx claudepluginhub chainguard-demo/claude-plugins --plugin chainguard-codegenRecommends full git SHA tagging for Docker images to enable instant code traceability in production incidents. Covers OCI labels, registry retention policies, and pitfalls of latest, date, or env tags.
Hardens Docker/container images and runtime deployments with secure base images, non-root users, CVE scanning, SBOM/signing, seccomp/AppArmor, and Kubernetes pod security controls.
Provides Docker security guidelines covering image selection, minimal bases, build/runtime protections, network isolation, least privilege, and defense-in-depth strategies. Useful for securing containers.