Skill v1.0.1
currentAutomated scan100/100+4 new
name: dockerfile-generation description: Generate maintainable Dockerfiles from application runtime requirements, build inputs, security constraints, and deployment targets. metadata: source: skills/05-code/dockerfile-generation.md category: 05-code version: "v2"
[Image: Dependency Status]
Dockerfile Generation
Category: code Skill Level: advanced Stability: stable Added: 2026-09
Description
Generate maintainable Dockerfiles from application runtime requirements, build inputs, security constraints, and deployment targets. The skill is evidence-first: inspect actual state before acting, preserve existing contracts, and verify the result before reporting completion.
Inputs / Outputs
| Direction | Field | Type | Contract | |
|---|---|---|---|---|
| Input | runtime | object | Language, version, build system, and entrypoint verified from the repository | |
| Input | constraints | object | Base-image policy, image size, user privilege, and pinning requirements | |
| Output | dockerfile | string | Layer-ordered, pinned, non-root container build definition | |
| Output | verification | object | Build and container run evidence confirming startup behavior |
Procedure
- Verify the runtime version and dependency manifests from the repository, not from memory.
- Pin the base image by exact version or digest; prefer minimal official images.
- Order layers from least to most volatile so dependency layers cache.
- Run as a non-root user; copy only required artifacts; declare ports and health semantics explicitly.
- Build the image and run the container; verify the entrypoint behaves as documented.
- Record the build command and verification output as evidence.
Example
plan = {'base': 'python:3.12-slim', 'layers': ['deps', 'source', 'config'], 'user': 'appuser'}assert plan['base'].endswith('slim')assert plan['user'] != 'root'assert plan['layers'].index('deps') < plan['layers'].index('source')print('dockerfile plan ordered for cache and least privilege')
Related Skills
- Dependency Management - pin the dependencies the image installs
- Code Execution Sandbox - verify image behavior in isolation
- Documentation Generation - document build and run commands
Failure Modes
- Guessing runtime dependencies instead of reading the manifests.
- Using unpinned or unverified base images.
- Skipping the image build and container startup check.
- Baking secrets into layers.
Changelog
- v2 (2026-11): Structural modernization; added the input/output contract table, a deterministic plan example, an execution procedure, and corpus-verified related links.
- v1 (2026-09): Initial entry.
Evidence
- https://agentskills.io/specification
Evidence status: implementation guidance only; no benchmark claim is made without reproducible evidence.