Agent skill
docker
Containerisation best practices, image optimisation, and multi-container orchestration
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/other/docker-baphled-dotopencode
SKILL.md
Skill: docker
What I do
I provide expertise in containerisation using Docker. I focus on creating reproducible development environments, building optimised production images, and orchestrating multi-service applications.
When to use me
- Building production-ready container images
- Optimising build times and image sizes
- Defining multi-service stacks with Docker Compose
- Implementing multi-stage builds for compiled languages
- Ensuring consistent environments across dev, test, and prod
Core principles
- Reproducibility — Environments should be identical regardless of the host
- Immutability — Images are never modified once built; they are replaced
- Layer Optimisation — Order commands to maximise cache hits
- Security — Use minimal base images and run as non-root users
- Isolation — Each container should have a single responsibility
Patterns & examples
Optimised Multi-stage Build:
# Stage 1: Build
FROM golang:1.21-alpine AS builder
WORKDIR /src
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN go build -o /app/bin/server
# Stage 2: Runtime (Minimal)
FROM alpine:3.18
RUN adduser -D -u 1000 appuser
USER appuser
COPY --from=builder /app/bin/server /server
ENTRYPOINT ["/server"]
Layer Caching (Correct Order):
FROM node:20-slim
WORKDIR /app
# Install dependencies first (infrequent changes)
COPY package.json package-lock.json ./
RUN npm ci
# Copy source code last (frequent changes)
COPY . .
CMD ["npm", "start"]
Anti-patterns to avoid
- ❌ Running as root — Increases attack surface; always use a non-privileged user
- ❌ Bloated base images — Avoid
ubuntuor fullnodeimages; usealpineorslim - ❌ Secrets in Dockerfile — Never use
ENVorARGfor passwords or API keys - ❌ Hardcoded Config — Use environment variables or volume mounts instead
- ❌ Large Layers — Don't combine unrelated files; keep
.dockerignoreupdated
KB Reference
~/vaults/baphled/3. Resources/Knowledge Base/AI Development System/Skills/DevOps-Operations/Docker.md
Related skills
devops- Broader operational patternsinfrastructure-as-code- Provisioning container hostsautomation- CI/CD integration for container buildssecurity- Scanning images for vulnerabilities
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?