
docker-patterns
โ 108by langchain-ai ยท part of langchain-ai/skills-benchmarks
Best practices for Docker containerization and multi-stage builds
๐ฅ๐ฅ๐ฅโ VerifiedFreeQuick setup
๐งฉ One of 7 skills in the langchain-ai/skills-benchmarks package โ works on its own, and pairs well with its siblings.
This is the playbook your agent receives when the skill activates โ you don't need to read it to use the skill, but it's here to audit before installing.
Docker Containerization Patterns
Build efficient, secure Docker images using modern patterns.
Multi-Stage Builds
Always use multi-stage builds to minimize image size:
# Build stage
FROM node:20-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
# Production stage
FROM node:20-alpine
WORKDIR /app
COPY --from=builder /app/node_modules ./node_modules
COPY . .
USER node
CMD ["node", "server.js"]Security Best Practices
- Never run as root - use
USERdirective - Use specific version tags, not
latest - Scan images with
docker scoutor Trivy - Use
.dockerignoreto exclude sensitive files
Health Checks
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD curl -f http://localhost:3000/health || exit 1Compose Patterns
services:
app:
build:
context: .
target: production
environment:
- NODE_ENV=production
deploy:
resources:
limits:
memory: 512MCopy & paste โ that's it
npx skills add langchain-ai/skills-benchmarks --skill "docker-patterns" --full-depthRun this in your project โ your agent picks the skill up automatically.
No common issues documented yet. If you hit a problem, the repository's GitHub Issues page is the best place to look.
Licensed under MITโ you can use, modify, and redistribute it under that license's terms.
View the full license file on GitHub โ