containers
Skill33 starsChanged 34 days agoMITView on GitHub
Use when building or debugging container images. Covers multi-stage builds, layer caching, image size, non-root users, signal handling, and the security defaults most Dockerfiles get wrong. Trigger on "my docker image is 2gb", "container exits immediately", "container ignores sigterm". Do not use for pods, deployments, or cluster scheduling — see the kubernetes skill; for vulnerable dependencies and image provenance, see the supply-chain skill.
7 other projects use a version of this.
Adopted by
Most recently taken up by
- seayniclabs/homelab-infra-mcptheir own version, first seen Nov 8, 2026
- microsoft/azure-dev-toolstheir own version, first seen Oct 25, 2026
- BrendenKennedy/claude-for-ai-platformstheir own version, first seen Oct 13, 2026
- sentineldesk/agenttheir own version, first seen Aug 24, 2026
- weiweimhy/agent-skillstheir own version, first seen Jul 1, 2026
- zllovesuki/cloudflare-agent-skillstheir own version, first seen Apr 28, 2026
Other versions7 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 7
- microsoft/azure-dev-tools★ 10same name
- zllovesuki/cloudflare-agent-skills★ 9same name
- ffsshhttiikk/opencode-agents-skills★ 2same name
- BrendenKennedy/claude-for-ai-platforms★ 1same name
- seayniclabs/homelab-infra-mcp★ 0same name
- sentineldesk/agent★ 0same name
- weiweimhy/agent-skills★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository137 other files it gives its agents.
- agent-instructionsSkill
- agent-memorySkill
- hooksSkill
- plugin-developmentSkill
- skill-authoringSkill
- skill-reviewSkill
- slash-commandsSkill
- subagentsSkill
- agent-designSkill
- context-engineeringSkill
- fine-tuningSkill
- llm-cost-optimizationSkill
- llm-evaluationSkill
- llm-integrationSkill
- mcp-serverSkill
- ml-pipelineSkill
- model-selectionSkill
- prompt-engineeringSkill
- ragSkill
- structured-outputSkill
- api-designSkill
- background-jobsSkill
- cachingSkill
- djangoSkill
- event-driven-architectureSkill
- fastapiSkill
- graphqlSkill
- microservicesSkill
- nestjsSkill
- realtime-websocketsSkill
- spring-bootSkill
- competitive-analysisSkill
- lead-researchSkill
- product-analysisSkill
- resumeSkill
- user-researchSkill
- database-performanceSkill
- data-modelingSkill
- data-qualitySkill
- pandasSkill
- postgresSkill
- sparkSkill
- brand-guidelinesSkill
- generative-artSkill
- themingSkill
- ui-reviewSkill
- visual-designSkill
- architecture-decisionsSkill
- bug-fix-protocolSkill
- cli-developmentSkill
- code-reviewSkill
- debuggingSkill
- design-patternsSkill
- domain-modelingSkill
- git-workflowSkill
- legacy-modernizationSkill
- refactoringSkill
- repository-explorationSkill
- simple-designSkill
- system-designSkill
- The first 60 shown.
The file
Files
Containers
Purpose
Build container images that are small, cached effectively, and safe to run — not a 1.2 GB image running as root that rebuilds from scratch every time a source file changes.
When to Use
- Writing or reviewing a Dockerfile.
- Reducing image size or build time.
- Debugging a container that exits, hangs, or behaves differently from local development.
- Hardening images before a security review.
Capabilities
- Multi-stage builds and build-cache optimization.
- Base-image selection: distroless, Alpine, slim, and their trade-offs.
- Non-root users, read-only filesystems, and dropped capabilities.
- Signal handling and PID 1 semantics.
- Image scanning and SBOM generation.
Inputs
- The application, its runtime, and its build steps.
- The target platform (including whether ARM builds are required).
- Security and compliance requirements.
Outputs
- A multi-stage Dockerfile with an ordered, cache-friendly layer sequence.
- An image running as a non-root user, with no build tooling inside.
- A scan report with no critical vulnerabilities in the final image.
Workflow
- Order layers by change frequency — Dependency manifests first, dependency install second, source code last. Copying the source before installing dependencies invalidates the cache on every code change.
- Build in stages — A build stage with compilers and dev dependencies; a runtime stage containing only the artifact and its runtime. The compiler must not ship to production.
- Run as non-root — Create a user in the image and
USERit. A container running as root that is compromised is a root process on the node. - Handle signals — Use exec form (
CMD ["node", "server.js"]), not shell form. Shell form makes/bin/shPID 1, which does not forward SIGTERM, so your graceful shutdown never runs. - Scan and pin — Pin the base image by digest, scan the final image, and rebuild regularly to pick up base-image patches.
Best Practices
COPY package*.json ./thenRUN npm cithenCOPY . .— in that order. This is the single most impactful Dockerfile optimization and it is routinely written backwards.- Shell-form
CMDmeans your process is not PID 1 and will not receive SIGTERM. Every "why doesn't my container shut down gracefully" question has this answer. - Distroless or
scratchimages have no shell, which is excellent for security and inconvenient for debugging. Usekubectl debugor a debug variant tag. - A
.dockerignorethat excludes.git,node_modules, and build output can cut the build context from hundreds of megabytes to a few. latestis not a version. Pin by digest for reproducibility, or at minimum by an immutable tag.- Secrets passed as build args are baked into the image layers and recoverable. Use BuildKit secret mounts.
Examples
Multi-stage build with correct caching, a non-root user, and exec-form CMD:
# syntax=docker/dockerfile:1
# ---- build stage: has the toolchain, ships nothing ----
FROM node:22-bookworm-slim AS build
WORKDIR /app
COPY package.json package-lock.json ./
RUN --mount=type=cache,target=/root/.npm \
npm ci # cached unless the lockfile changes
COPY . . # source last: code changes do not
RUN npm run build # invalidate the dependency layer
# ---- runtime stage: no compiler, no dev dependencies, no shell needed ----
FROM gcr.io/distroless/nodejs22-debian12@sha256:4c2e...
WORKDIR /app
COPY --from=build --chown=nonroot:nonroot /app/dist ./dist
COPY --from=build --chown=nonroot:nonroot /app/node_modules ./node_modules
USER nonroot # never root
EXPOSE 8080
CMD ["dist/server.js"] # exec form: the process is PID 1Secret at build time without baking it into a layer:
RUN --mount=type=secret,id=npm_token \
NPM_TOKEN=$(cat /run/secrets/npm_token) npm ciThe token is available during the command and absent from the resulting layer. A ARG NPM_TOKEN would be permanently recoverable with docker history.
Notes
docker history <image>shows every layer and the command that created it. Anything a build arg touched is visible there — which is why build args are not a secrets mechanism.- Alpine uses musl instead of glibc. It is smaller, but it has caused real production bugs with DNS resolution and with native Node modules.
slimvariants are usually the safer default. - A read-only root filesystem (
readOnlyRootFilesystem: true) with an explicit writableemptyDirfor temp files eliminates an entire class of container escape and persistence techniques.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

