containerize
Skill1 starsChanged 9 months agoMITView on GitHub
Designs and reviews containerization with Docker. Covers Dockerfile best practices, image optimization, multi-stage builds, Docker Compose for development, health checks, and security hardening. Use when containerizing applications, optimizing images, or reviewing Docker configurations.
- Reads credentials
- Installs packages
2 other projects use a version of this.
Adopted by
Most recently taken up by
- fmind/dottheir own version, first seen Oct 5, 2026
- aprameyak/coding-skillstheir own version, first seen Oct 2, 2026
Other versions2 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 2
- fmind/dot★ 10same name
- aprameyak/coding-skills★ 1same 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 repository48 other files it gives its agents.
- accessibilitySkill
- api-designSkill
- api-integrationSkill
- architectSkill
- async-patternsSkill
- best-practicesSkill
- bugSkill
- buildSkill
- cachingSkill
- ci-cdSkill
- config-managementSkill
- database-designSkill
- data-modelingSkill
- data-pipelineSkill
- debug-latencySkill
- dependency-updateSkill
- deploySkill
- dev-setupSkill
- docsSkill
- error-handlingSkill
- estimateSkill
- feature-flag-opsSkill
- git-recoverySkill
- i18nSkill
- iacSkill
- incidentSkill
- load-testingSkill
- loggingSkill
- migrateSkill
- monitoringSkill
- observability-debugSkill
- onboardSkill
- perfSkill
- phase-gateSkill
- pr-authorSkill
- qaSkill
- refactorSkill
- reviewSkill
- rollbackSkill
- schema-evolutionSkill
- scope-checkSkill
- security-auditSkill
- state-managementSkill
- tech-debtSkill
- tech-stackSkill
- telemetrySkill
- testingSkill
- workflowSkill
The file
We split this skill into the rules it gives an agent
4 rules. About 0 are common, 2 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 44
Rule: Put things that change less often earlier.
- Very specific: line 90
Use tini for proper signal handling (PID 1 problem)
- Distinctive: line 187
Never run as root in production.
- Very specific: line 193
Not just node:20 - pin the patch version AND the OS version for reproducibility.
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Containerization
A container should be: small, fast to build, secure, and reproducible. If rebuilding takes minutes or the image is gigabytes, something's wrong.
Dockerfile Best Practices
Multi-Stage Build (Always Use)
# Stage 1: Build
FROM node:20-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build
# Stage 2: Production
FROM node:20-alpine
WORKDIR /app
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/node_modules ./node_modules
COPY package*.json ./
USER node
EXPOSE 3000
CMD ["node", "dist/index.js"]Why multi-stage? Build tools, source code, and dev dependencies stay in the build stage. Production image contains only what's needed to run.
Layer Caching Order
# COPY in order of least → most frequently changing
COPY package*.json ./ # 1. Dependencies (changes rarely)
RUN npm ci # 2. Install (cached if package.json unchanged)
COPY . . # 3. Source code (changes every commit)
RUN npm run build # 4. Build (runs only if source changed)Rule: Put things that change less often earlier. Docker caches layers - changing a layer invalidates all subsequent layers.
Image Size Optimization
| Technique | Impact |
| Alpine base image | 5MB vs 900MB (Debian) |
| Multi-stage build | Remove build tools and source |
.dockerignore | Exclude node_modules, .git, tests, docs |
npm ci --omit=dev | No dev dependencies in production |
| Distroless base | Even smaller than Alpine, no shell |
.dockerignore
.git
node_modules
*.md
.env*
tests/
docs/
.github/
Dockerfile
docker-compose*.ymlLanguage-Specific Patterns
Node.js
FROM node:20-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build
FROM node:20-alpine
WORKDIR /app
RUN apk add --no-cache tini
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/node_modules ./node_modules
COPY package*.json ./
USER node
ENTRYPOINT ["tini", "--"]
CMD ["node", "dist/index.js"]- Use
tinifor proper signal handling (PID 1 problem) npm cinotnpm install(deterministic, faster)
Python
FROM python:3.12-slim AS builder
WORKDIR /app
COPY requirements.txt .
RUN pip install --user --no-cache-dir -r requirements.txt
FROM python:3.12-slim
WORKDIR /app
COPY --from=builder /root/.local /root/.local
COPY . .
ENV PATH=/root/.local/bin:$PATH
USER nobody
CMD ["python", "-m", "myapp"]Go
FROM golang:1.22-alpine AS builder
WORKDIR /app
COPY go.* ./
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 go build -o /app/server .
FROM scratch
COPY --from=builder /app/server /server
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
USER 65534
ENTRYPOINT ["/server"]scratchbase = literally empty. Binary + certs only.- Static binary with
CGO_ENABLED=0
Docker Compose for Development
services:
app:
build: .
ports:
- "3000:3000"
volumes:
- .:/app # Mount source for hot reload
- /app/node_modules # Don't overwrite container's node_modules
environment:
- DATABASE_URL=postgres://postgres:postgres@db:5432/myapp
- REDIS_URL=redis://redis:6379
depends_on:
db:
condition: service_healthy
redis:
condition: service_started
db:
image: postgres:16-alpine
environment:
POSTGRES_DB: myapp
POSTGRES_PASSWORD: postgres
volumes:
- pgdata:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 5s
timeout: 5s
retries: 5
redis:
image: redis:7-alpine
volumes:
pgdata:Health Checks
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost:3000/health || exit 1Your /health endpoint should check:
- Application is ready to serve requests
- Database connection is alive
- Critical dependencies are reachable
Security Hardening
Run as Non-Root
# Create a non-root user
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
USER appuserNever run as root in production. Most base images default to root.
Pin Versions
FROM node:20.11.1-alpine3.19 # Pin exact versionsNot just node:20 - pin the patch version AND the OS version for reproducibility.
No Secrets in Images
# WRONG: Secret baked into image layer
COPY .env /app/.env
ENV API_KEY=sk_live_xxx
# RIGHT: Pass at runtime
# docker run -e API_KEY=sk_live_xxx myappEven if you delete a file in a later layer, it exists in a previous layer. Docker layers are not secure deletion.
Scan for Vulnerabilities
docker scout cve myimage:latest # Docker Scout
trivy image myimage:latest # Trivy
snyk container test myimage:latest # SnykReference:
reference/container-patterns.md- base image comparison, multi-stage builds by language, layer caching, health checks, security checklist, resource limits, Compose vs Kubernetes.
Review Checklist
- Multi-stage build (build tools not in production image)
.dockerignoreexcludes unnecessary files- Layer order optimized for caching
- Runs as non-root user
- Base image pinned to specific version
- No secrets in image layers
- Health check defined
- Proper signal handling (tini or dumb-init for Node.js)
- Image size reasonable (< 200MB for most apps)
- Development compose file with volume mounts and service dependencies
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.

