Skip to content
/dockerStable

Build, optimize, and debug Docker containers and compose files. Analyzes Dockerfiles for security, size, and performance.

DevOpsContainersΒ· 2 min read

Quick import: Download the .md file and save it to .claude/commands/ (Claude Code), .cursorrules (Cursor), or paste as a system prompt in ChatGPT, Gemini, or any LLM API.

#What it does

The /docker skill analyzes your project and generates production-ready Dockerfiles and Compose configurations. It catches common mistakes like running as root, bloated images, missing health checks, and inefficient layer caching.

#How to use

bash
/docker
/docker optimize
/docker compose

#Workflow

  1. Detect -- Scans the project to identify the runtime, package manager, and framework
  2. Generate -- Creates a multi-stage Dockerfile optimized for your stack
  3. Audit -- Reviews existing Dockerfiles for security and size issues
  4. Compose -- Generates docker-compose.yml with services, volumes, and networks
  5. Verify -- Runs a test build and reports the final image size

#What it catches

  • Security -- Running as root, exposing unnecessary ports, hardcoded secrets in layers
  • Size -- Missing multi-stage builds, dev dependencies in production, unneeded system packages
  • Caching -- Inefficient layer ordering that invalidates cache on every code change
  • Health -- Missing HEALTHCHECK instructions, no graceful shutdown handling

#Example

bash
> /docker optimize
 
# Analyzing Dockerfile...
! Running as root user (add USER directive)
! COPY . . before dependency install (cache invalidation)
! Image size: 1.2GB (switch to alpine base: ~180MB)
! No HEALTHCHECK defined
 
# Generating optimized Dockerfile...
FROM node:20-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci --omit=dev
COPY . .
RUN npm run build
 
FROM node:20-alpine
RUN addgroup -S app && adduser -S app -G app
USER app
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/node_modules ./node_modules
HEALTHCHECK CMD wget -q --spider http://localhost:3000/health
EXPOSE 3000
CMD ["node", "dist/server.js"]
 
# Result: 1.2GB -> 178MB (85% reduction)
Orel OhayonΒ·
View all skills