# Docker Expert

> Build optimized, secure Docker images with multi-stage builds. Configure Docker Compose for full development and production stacks.

- Skill: `atulpurohit/docker-expert` (Agent Skill)
- Install (CLI): `npx skillmds@latest add atulpurohit/docker-expert`
- Raw SKILL.md: https://api.skillmd.com/api/skills/atulpurohit/docker-expert/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: DevOps & Infra
- Author: AtulPurohit (https://skillmd.com/u/atulpurohit)
- Updated: 2026-09-21
- Page: https://skillmd.com/skills/atulpurohit/docker-expert

---


# Docker Expert

## Purpose
Create production-ready Docker images and container orchestration setups that are secure, minimal, and efficient.

## Optimized Multi-Stage Dockerfile
```dockerfile
# Node.js production example
FROM node:20-alpine AS base
WORKDIR /app
COPY package*.json ./

FROM base AS deps
RUN npm ci --only=production && npm cache clean --force

FROM base AS builder
RUN npm ci
COPY . .
RUN npm run build

FROM node:20-alpine AS production
WORKDIR /app

# Security: non-root user
RUN addgroup -S app && adduser -S appuser -G app
USER appuser

COPY --from=deps --chown=appuser:app /app/node_modules ./node_modules
COPY --from=builder --chown=appuser:app /app/dist ./dist
COPY --chown=appuser:app package.json .

EXPOSE 3000
HEALTHCHECK --interval=30s --timeout=10s   CMD wget -qO- http://localhost:3000/health || exit 1

CMD ["node", "dist/server.js"]
```

## Docker Compose (Production)
```yaml
services:
  app:
    build: { context: ., target: production }
    environment:
      DATABASE_URL: postgresql://app:${DB_PASSWORD}@db:5432/myapp
    depends_on:
      db: { condition: service_healthy }
    restart: unless-stopped

  db:
    image: postgres:16-alpine
    environment:
      POSTGRES_USER: app
      POSTGRES_PASSWORD: ${DB_PASSWORD}
      POSTGRES_DB: myapp
    volumes:
      - postgres_data:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U app"]
      interval: 10s

  nginx:
    image: nginx:alpine
    ports: ["80:80", "443:443"]
    volumes:
      - ./nginx.conf:/etc/nginx/conf.d/default.conf:ro
    depends_on: [app]

volumes:
  postgres_data:
```

## .dockerignore
```
node_modules
.git
.env*
*.md
coverage
.nyc_output
dist
```

## Security Best Practices
- Pin image versions: `node:20.11.0-alpine` not `node:alpine`
- Scan: `docker scout cves my-image`
- Run as non-root
- Use secrets mount for sensitive build args
- Minimize layers in production image

## Outputs
1. Optimized Dockerfile for your stack
2. Docker Compose configuration
3. .dockerignore template
4. Security scanning setup
5. Production health check configuration

