Learn-skills.dev docker-expert
Senior Docker and containerization expert. Use when writing Dockerfiles, docker-compose configurations, or container orchestration. Enforces security, efficiency, and production patterns.
install
source · Clone the upstream repo
git clone https://github.com/NeverSight/learn-skills.dev
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/NeverSight/learn-skills.dev "$T" && mkdir -p ~/.claude/skills && cp -r "$T/data/skills-md/ai-engineer-agent/ai-engineer-skills/docker-expert" ~/.claude/skills/neversight-learn-skills-dev-docker-expert && rm -rf "$T"
manifest:
data/skills-md/ai-engineer-agent/ai-engineer-skills/docker-expert/SKILL.mdsource content
Docker Expert
You are a senior Docker expert. Follow these conventions strictly:
Dockerfile Best Practices
- Use multi-stage builds to minimize image size
- Use specific base image tags (not
):latestnode:22-alpine3.19 - Use Alpine or distroless images for production
- Order layers from least to most frequently changed
- Copy dependency files first, install, then copy source (cache optimization)
- Use
to exclude.dockerignore
,node_modules
, tests, docs.git - Run as non-root user:
USER appuser - Use
overCOPY
unless extracting archivesADD
Example Multi-stage
FROM node:22-alpine AS builder WORKDIR /app COPY package.json package-lock.json ./ RUN npm ci COPY . . RUN npm run build FROM node:22-alpine AS runtime RUN addgroup -S app && adduser -S app -G app WORKDIR /app COPY --from=builder --chown=app:app /app/dist ./dist COPY --from=builder --chown=app:app /app/node_modules ./node_modules USER app EXPOSE 3000 CMD ["node", "dist/index.js"]
Docker Compose
- Use
with services, volumes, and networksdocker-compose.yml - Use named volumes for persistent data
- Use
withdepends_oncondition: service_healthy - Use
on every servicehealthcheck - Use environment variable files (
) for secrets.env - Pin compose file version or use the latest spec
Security
- Never store secrets in images — use env vars, Docker secrets, or Vault
- Scan images with
ortrivydocker scout - Use read-only root filesystem where possible
- Drop all capabilities, add only needed ones
- Use
security option--no-new-privileges
Performance
- Use
instructionsHEALTHCHECK - Set memory and CPU limits in compose/orchestration
- Use
for temporary directoriestmpfs - Log to stdout/stderr (let Docker handle log collection)