# Multi-stage build
FROM node:20-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY . .
RUN npm run build
FROM node:20-alpine AS runtime
WORKDIR /app
RUN addgroup -g 1001 appgroup && adduser -u 1001 -G appgroup -s /bin/sh -D appuser
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/node_modules ./node_modules
USER appuser
EXPOSE 3000
HEALTHCHECK --interval=30s --timeout=3s CMD wget -q --spider http://localhost:3000/health || exit 1
CMD ["node", "dist/server.js"]
Anti-Patterns
Do NOT run containers as root
Do NOT include dev dependencies in production images
Do NOT hardcode secrets (use env vars or secrets management)
Do NOT use latest tag in production
Do NOT skip health checks
Checklist
Multi-stage build used
Non-root user configured
Health check defined
.dockerignore is comprehensive
No secrets in image; image size is optimized
1---2name: docker3description: Docker Skill4---5# Docker Skill67> Loaded by: DevOps Division agents | Version: 1.089## Dockerfile Pattern1011```dockerfile12# Multi-stage build13FROM node:20-alpine AS builder14WORKDIR /app15COPY package*.json ./16RUN npm ci --only=production17COPY . .18RUN npm run build1920FROM node:20-alpine AS runtime21WORKDIR /app22RUN addgroup -g 1001 appgroup && adduser -u 1001 -G appgroup -s /bin/sh -D appuser23COPY --from=builder /app/dist ./dist24COPY --from=builder /app/node_modules ./node_modules25USER appuser26EXPOSE 300027HEALTHCHECK --interval=30s --timeout=3s CMD wget -q --spider http://localhost:3000/health || exit 128CMD ["node", "dist/server.js"]29```3031## Anti-Patterns3233- Do NOT run containers as root34- Do NOT include dev dependencies in production images35- Do NOT hardcode secrets (use env vars or secrets management)36- Do NOT use `latest` tag in production37- Do NOT skip health checks3839## Checklist4041- [ ] Multi-stage build used42- [ ] Non-root user configured43- [ ] Health check defined44- [ ] .dockerignore is comprehensive45- [ ] No secrets in image; image size is optimized
Run npx skillmds@latest add ab-aswini/docker in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
Docker Skill It is listed under DevOps & Infra on SkillMD.
This skill has not completed SkillMD's automated safety review yet. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
Ab-aswini (@ab-aswini) published this skill. Their other Agent Skills are listed on their SkillMD profile.