[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6E25GZSJBAJ409E6W6TD8RJ":3,"skill-same:01M6E25GZSJBAJ409E6W6TD8RJ":70},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":39,"linkOnly":40,"markdownContent":41,"markdownBody":42,"frontMatter":43,"refName":48,"commitSha":49,"skillDirectory":50,"forksCount":51,"repositoryHtmlUrl":52,"repositoryHomepageUrl":6,"ownerHtmlUrl":53,"ownerBlogUrl":6,"ownerDescription":54,"updatedAt":55,"install":56,"resources":69},"01M6E25GZSJBAJ409E6W6TD8RJ","docker-expert",null,"Expert-level Docker and containerization. Use when writing Dockerfiles, docker-compose files, multi-stage builds, optimizing image size, container networking, volumes, secrets, health checks, or debugging container issues. Also use when the user mentions 'Dockerfile', 'docker-compose', 'container', 'image size', 'layer cache', 'registry', 'container wont start', or 'docker build'.","luokai0\u002Fai-agent-skills-by-luo-kai","luokai0","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F266954973?v=4","01M6E16VNT42JB8B3X3254QWJ7","luo kai","01M6E16VTFVP6S5XJF1V1MPV90",14,"MIT","https:\u002F\u002Fgithub.com\u002Fluokai0\u002Fai-agent-skills-by-luo-kai\u002Fblob\u002Fmain\u002Fai-agent-skills\u002F05-devops-and-cloud (by Luo Kai)\u002F05-docker-containers\u002Fdocker-expert\u002FSKILL.md",[],[19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38],"docker","expert","docker expert","health","stage","docker-compose","build","files","compose","containerization","container","use","writing","secrets","start","cache","issues","debugging","dockerfile","image","2026-11-10 10:12:30",false,"---\nauthor: luo-kai\nname: docker-expert\ndescription: Expert-level Docker and containerization. Use when writing Dockerfiles, docker-compose files, multi-stage builds, optimizing image size, container networking, volumes, secrets, health checks, or debugging container issues. Also use when the user mentions 'Dockerfile', 'docker-compose', 'container', 'image size', 'layer cache', 'registry', 'container wont start', or 'docker build'.\nlicense: MIT\nmetadata:\n  author: luokai0\n  version: \"1.0\"\n  category: coding\n---\n\n# Docker Expert\n\nYou are an expert in Docker and containerization with deep knowledge of container internals, image optimization, and production deployment patterns.\n\n## Before Starting\n\n1. **Language\u002Fruntime** — Node.js, Python, Go, Java, Rust?\n2. **Use case** — development, production, CI\u002FCD?\n3. **Compose or single container?**\n4. **Specific issue?** — image too large, build too slow, networking problem, container crashes?\n\n---\n\n## Core Expertise Areas\n\n- **Dockerfile optimization**: layer caching order, multi-stage builds, .dockerignore, ARG vs ENV\n- **Security**: non-root users, read-only filesystems, minimal base images, image scanning\n- **docker-compose**: service dependencies, health checks, networks, profiles, override files\n- **Networking**: bridge, host, overlay networks, DNS resolution between containers\n- **Volumes**: named volumes, bind mounts, tmpfs, volume drivers\n- **Production patterns**: resource limits, restart policies, init processes (tini\u002Fdumb-init)\n- **Registry**: image tagging strategies, multi-arch builds with buildx, SBOM\n- **Debugging**: exec, logs, inspect, events, stats, copying files out of containers\n\n---\n\n## Key Patterns & Code\n\n### Optimized Multi-Stage Dockerfile — Node.js\n```dockerfile\n# ─── Stage 1: Install production dependencies ───────────────────────────────\nFROM node:20-alpine AS deps\nWORKDIR \u002Fapp\n\n# Copy ONLY package files first — layer cached until these change\nCOPY package.json package-lock.json .\u002F\nRUN npm ci --only=production && npm cache clean --force\n\n# ─── Stage 2: Build ──────────────────────────────────────────────────────────\nFROM node:20-alpine AS builder\nWORKDIR \u002Fapp\n\nCOPY package.json package-lock.json .\u002F\nRUN npm ci\n\nCOPY . .\nRUN npm run build\n\n# ─── Stage 3: Production image (minimal) ─────────────────────────────────────\nFROM node:20-alpine AS runner\nWORKDIR \u002Fapp\n\n# Security: create non-root user\nRUN addgroup --system --gid 1001 nodejs \\\n    && adduser --system --uid 1001 --ingroup nodejs appuser\n\n# Copy only what is needed from previous stages\nCOPY --from=deps    --chown=appuser:nodejs \u002Fapp\u002Fnode_modules .\u002Fnode_modules\nCOPY --from=builder --chown=appuser:nodejs \u002Fapp\u002Fdist        .\u002Fdist\nCOPY --from=builder --chown=appuser:nodejs \u002Fapp\u002Fpackage.json .\u002F\n\nUSER appuser\nEXPOSE 3000\nENV NODE_ENV=production PORT=3000\n\n# Health check — orchestrators use this to know when app is ready\nHEALTHCHECK \\\n  --interval=30s \\\n  --timeout=10s \\\n  --start-period=40s \\\n  --retries=3 \\\n  CMD wget -qO- http:\u002F\u002Flocalhost:3000\u002Fhealth || exit 1\n\nENTRYPOINT [\"node\", \"dist\u002Fserver.js\"]\n```\n\n### Optimized Multi-Stage Dockerfile — Python\n```dockerfile\n# ─── Stage 1: Build dependencies ─────────────────────────────────────────────\nFROM python:3.12-slim AS builder\nWORKDIR \u002Fapp\n\nRUN pip install --upgrade pip\nCOPY requirements.txt .\nRUN pip install --prefix=\u002Finstall --no-cache-dir -r requirements.txt\n\n# ─── Stage 2: Production image ───────────────────────────────────────────────\nFROM python:3.12-slim AS runner\nWORKDIR \u002Fapp\n\n# Non-root user\nRUN useradd --system --uid 1001 --no-create-home appuser\n\n# Copy installed packages from builder\nCOPY --from=builder \u002Finstall \u002Fusr\u002Flocal\n\nCOPY --chown=appuser:appuser . .\n\nUSER appuser\nEXPOSE 8000\n\nHEALTHCHECK --interval=30s --timeout=10s --retries=3 \\\n  CMD python -c \"import urllib.request; urllib.request.urlopen('http:\u002F\u002Flocalhost:8000\u002Fhealth')\"\n\nCMD [\"python\", \"-m\", \"uvicorn\", \"main:app\", \"--host\", \"0.0.0.0\", \"--port\", \"8000\"]\n```\n\n### Optimized Multi-Stage Dockerfile — Go\n```dockerfile\n# ─── Stage 1: Build ──────────────────────────────────────────────────────────\nFROM golang:1.22-alpine AS builder\nWORKDIR \u002Fapp\n\n# Download dependencies first (cached layer)\nCOPY go.mod go.sum .\u002F\nRUN go mod download\n\nCOPY . .\n\n# Build static binary — no external dependencies\nRUN CGO_ENABLED=0 GOOS=linux go build \\\n    -ldflags=\"-w -s\" \\\n    -o server .\u002Fcmd\u002Fserver\n\n# ─── Stage 2: Minimal production image ───────────────────────────────────────\n# distroless: no shell, no package manager — smallest attack surface\nFROM gcr.io\u002Fdistroless\u002Fstatic-debian12 AS runner\n\nCOPY --from=builder \u002Fapp\u002Fserver \u002Fserver\n\nEXPOSE 8080\nUSER nonroot:nonroot\n\nENTRYPOINT [\"\u002Fserver\"]\n```\n\n### .dockerignore — Always Create This\n```\n# Version control\n.git\n.gitignore\n\n# Dependencies (always reinstalled in container)\nnode_modules\nvendor\n__pycache__\n*.pyc\n.venv\nvenv\n\n# Build artifacts\ndist\nbuild\n.next\nout\ntarget\n\n# Test & coverage\ncoverage\n*.test\n.pytest_cache\n__tests__\n\n# Environment files — NEVER include these\n.env\n.env.*\n*.env\n\n# Logs\n*.log\nlogs\n\n# Editor\n.vscode\n.idea\n*.swp\n*.swo\n\n# Docker files themselves\ndocker-compose*.yml\nDockerfile*\n\n# Docs\nREADME.md\nCHANGELOG.md\ndocs\n```\n\n### docker-compose — Production Pattern\n```yaml\nversion: \"3.9\"\n\nservices:\n  api:\n    build:\n      context: .\n      target: runner        # use specific build stage\n      cache_from:\n        - type=registry,ref=myregistry\u002Fmyapp:cache\n    image: myregistry\u002Fmyapp:${TAG:-latest}\n    ports:\n      - \"3000:3000\"\n    environment:\n      NODE_ENV: production\n      DATABASE_URL: postgresql:\u002F\u002Fuser:pass@db:5432\u002Fmydb\n      REDIS_URL: redis:\u002F\u002Fcache:6379\n    depends_on:\n      db:\n        condition: service_healthy\n      cache:\n        condition: service_healthy\n    restart: unless-stopped\n    deploy:\n      resources:\n        limits:\n          memory: 512M\n          cpus: \"0.5\"\n        reservations:\n          memory: 256M\n    read_only: true           # security: read-only filesystem\n    tmpfs:\n      - \u002Ftmp                  # writable temp dir\n    networks:\n      - app-net\n    logging:\n      driver: \"json-file\"\n      options:\n        max-size: \"10m\"\n        max-file: \"3\"\n\n  db:\n    image: postgres:16-alpine\n    environment:\n      POSTGRES_DB: mydb\n      POSTGRES_USER: user\n      POSTGRES_PASSWORD_FILE: \u002Frun\u002Fsecrets\u002Fdb_password\n    secrets:\n      - db_password\n    volumes:\n      - pgdata:\u002Fvar\u002Flib\u002Fpostgresql\u002Fdata\n      - .\u002Finit.sql:\u002Fdocker-entrypoint-initdb.d\u002Finit.sql:ro\n    healthcheck:\n      test: [\"CMD-SHELL\", \"pg_isready -U user -d mydb\"]\n      interval: 10s\n      timeout: 5s\n      retries: 5\n      start_period: 30s\n    restart: unless-stopped\n    networks:\n      - app-net\n\n  cache:\n    image: redis:7-alpine\n    command: redis-server --maxmemory 256mb --maxmemory-policy allkeys-lru\n    healthcheck:\n      test: [\"CMD\", \"redis-cli\", \"ping\"]\n      interval: 10s\n      timeout: 5s\n      retries: 5\n    restart: unless-stopped\n    networks:\n      - app-net\n\n  nginx:\n    image: nginx:alpine\n    ports:\n      - \"80:80\"\n      - \"443:443\"\n    volumes:\n      - .\u002Fnginx.conf:\u002Fetc\u002Fnginx\u002Fnginx.conf:ro\n      - .\u002Fcerts:\u002Fetc\u002Fnginx\u002Fcerts:ro\n    depends_on:\n      - api\n    restart: unless-stopped\n    networks:\n      - app-net\n\nvolumes:\n  pgdata:\n    driver: local\n\nnetworks:\n  app-net:\n    driver: bridge\n\nsecrets:\n  db_password:\n    file: .\u002Fsecrets\u002Fdb_password.txt\n```\n\n### docker-compose Override for Development\n```yaml\n# docker-compose.override.yml — auto-loaded in development\nversion: \"3.9\"\n\nservices:\n  api:\n    build:\n      target: builder       # use dev stage with devDependencies\n    volumes:\n      - .:\u002Fapp              # bind mount source for hot reload\n      - \u002Fapp\u002Fnode_modules   # anonymous volume to preserve container's node_modules\n    environment:\n      NODE_ENV: development\n      DEBUG: \"*\"\n    command: npm run dev    # override production command\n    ports:\n      - \"9229:9229\"         # Node.js debugger port\n\n  db:\n    ports:\n      - \"5432:5432\"         # expose for local tools like pgAdmin\n\n  cache:\n    ports:\n      - \"6379:6379\"         # expose for local Redis tools\n```\n\n### Networking Patterns\n```bash\n# Containers on same network communicate by service name\n# api → db:5432 (service name = hostname)\n# api → cache:6379\n\n# Inspect container network\ndocker inspect mycontainer | jq '.[0].NetworkSettings.Networks'\n\n# Connect running container to another network\ndocker network connect my-network my-container\n\n# Create custom network with specific subnet\ndocker network create \\\n  --driver bridge \\\n  --subnet 172.20.0.0\u002F16 \\\n  --ip-range 172.20.240.0\u002F20 \\\n  my-custom-net\n\n# List all networks\ndocker network ls\n\n# Remove unused networks\ndocker network prune\n```\n\n### Debugging Commands\n```bash\n# Get interactive shell in running container\ndocker exec -it \u003Ccontainer_name> sh\n\n# Debug a stopped or crashing container\n# Override entrypoint to get shell\ndocker run --rm -it --entrypoint sh myimage:latest\n\n# Follow logs with timestamps\ndocker logs -f --timestamps --tail=100 \u003Ccontainer_name>\n\n# Copy files out of container for inspection\ndocker cp \u003Ccontainer_name>:\u002Fapp\u002Flogs\u002Ferror.log .\u002Ferror.log\n\n# Real-time resource usage\ndocker stats --no-stream\n\n# Inspect everything about a container\ndocker inspect \u003Ccontainer_name>\n\n# View image layers and sizes\ndocker history myimage:latest --human --no-trunc\n\n# Check what changed in container filesystem vs image\ndocker diff \u003Ccontainer_name>\n\n# Scan image for vulnerabilities\ndocker scout cves myimage:latest\n\n# Build with detailed output for debugging cache\ndocker build --progress=plain --no-cache .\n\n# Check why container exited\ndocker inspect \u003Ccontainer_name> | jq '.[0].State'\n```\n\n### Multi-Arch Build with Buildx\n```bash\n# Create and use a buildx builder\ndocker buildx create --name mybuilder --use\ndocker buildx inspect --bootstrap\n\n# Build for multiple architectures and push\ndocker buildx build \\\n  --platform linux\u002Famd64,linux\u002Farm64 \\\n  --tag myregistry\u002Fmyapp:latest \\\n  --push \\\n  .\n\n# Build with cache export to registry\ndocker buildx build \\\n  --cache-from type=registry,ref=myregistry\u002Fmyapp:cache \\\n  --cache-to type=registry,ref=myregistry\u002Fmyapp:cache,mode=max \\\n  --tag myregistry\u002Fmyapp:latest \\\n  --push \\\n  .\n```\n\n### Health Check Patterns\n```dockerfile\n# HTTP health check\nHEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \\\n  CMD wget -qO- http:\u002F\u002Flocalhost:3000\u002Fhealth || exit 1\n\n# TCP health check (when no HTTP endpoint)\nHEALTHCHECK --interval=10s --timeout=5s --retries=5 \\\n  CMD nc -z localhost 5432 || exit 1\n\n# Custom script health check\nCOPY healthcheck.sh \u002Fhealthcheck.sh\nRUN chmod +x \u002Fhealthcheck.sh\nHEALTHCHECK --interval=30s CMD \u002Fhealthcheck.sh\n```\n\n---\n\n## Best Practices\n\n- Always use specific image tags — never `latest` in production (`node:20-alpine` not `node:latest`)\n- Always create `.dockerignore` — dramatically speeds up builds and reduces context size\n- Run as non-root user in every production container\n- Use multi-stage builds — final image should contain only what is needed to run\n- Set memory and CPU limits — prevent one container from starving others\n- Add `HEALTHCHECK` to every production image\n- Use `read_only: true` + `tmpfs` for `\u002Ftmp` — better security posture\n- Never put secrets in `ENV` or `ARG` — use Docker secrets or secret mounts\n- Pin base image digests for reproducibility in critical systems\n- Use `dumb-init` or `tini` as PID 1 to handle signals properly\n\n---\n\n## Common Pitfalls\n\n| Pitfall | Problem | Fix |\n|---|---|---|\n| No `.dockerignore` | Huge build context, slow builds, secrets leaked | Always create `.dockerignore` |\n| Running as root | Security vulnerability | Add non-root user in Dockerfile |\n| Copy source before package.json | Cache busted on every code change | Copy package.json first, then source |\n| Secrets in `ENV` or `ARG` | Visible in `docker inspect` and image history | Use `--secret` mount or Docker secrets |\n| No health check | Orchestrator cannot detect unhealthy app | Add `HEALTHCHECK` instruction |\n| `latest` tag | Non-deterministic, impossible to rollback | Always pin exact version tags |\n| One huge RUN command | Hard to debug layer failures | Split logical steps into separate RUN |\n| No resource limits | One container can OOM the host | Always set memory limits in production |\n\n---\n\n## Related Skills\n\n- **kubernetes-expert**: For orchestrating containers at scale\n- **cicd-expert**: For Docker in CI\u002FCD pipelines\n- **nginx-expert**: For Nginx as a reverse proxy in containers\n- **linux-expert**: For Linux container internals\n- **aws-expert**: For ECR, ECS, and EKS on AWS\n","# Docker Expert\n\nYou are an expert in Docker and containerization with deep knowledge of container internals, image optimization, and production deployment patterns.\n\n## Before Starting\n\n1. **Language\u002Fruntime** — Node.js, Python, Go, Java, Rust?\n2. **Use case** — development, production, CI\u002FCD?\n3. **Compose or single container?**\n4. **Specific issue?** — image too large, build too slow, networking problem, container crashes?\n\n---\n\n## Core Expertise Areas\n\n- **Dockerfile optimization**: layer caching order, multi-stage builds, .dockerignore, ARG vs ENV\n- **Security**: non-root users, read-only filesystems, minimal base images, image scanning\n- **docker-compose**: service dependencies, health checks, networks, profiles, override files\n- **Networking**: bridge, host, overlay networks, DNS resolution between containers\n- **Volumes**: named volumes, bind mounts, tmpfs, volume drivers\n- **Production patterns**: resource limits, restart policies, init processes (tini\u002Fdumb-init)\n- **Registry**: image tagging strategies, multi-arch builds with buildx, SBOM\n- **Debugging**: exec, logs, inspect, events, stats, copying files out of containers\n\n---\n\n## Key Patterns & Code\n\n### Optimized Multi-Stage Dockerfile — Node.js\n```dockerfile\n# ─── Stage 1: Install production dependencies ───────────────────────────────\nFROM node:20-alpine AS deps\nWORKDIR \u002Fapp\n\n# Copy ONLY package files first — layer cached until these change\nCOPY package.json package-lock.json .\u002F\nRUN npm ci --only=production && npm cache clean --force\n\n# ─── Stage 2: Build ──────────────────────────────────────────────────────────\nFROM node:20-alpine AS builder\nWORKDIR \u002Fapp\n\nCOPY package.json package-lock.json .\u002F\nRUN npm ci\n\nCOPY . .\nRUN npm run build\n\n# ─── Stage 3: Production image (minimal) ─────────────────────────────────────\nFROM node:20-alpine AS runner\nWORKDIR \u002Fapp\n\n# Security: create non-root user\nRUN addgroup --system --gid 1001 nodejs \\\n    && adduser --system --uid 1001 --ingroup nodejs appuser\n\n# Copy only what is needed from previous stages\nCOPY --from=deps    --chown=appuser:nodejs \u002Fapp\u002Fnode_modules .\u002Fnode_modules\nCOPY --from=builder --chown=appuser:nodejs \u002Fapp\u002Fdist        .\u002Fdist\nCOPY --from=builder --chown=appuser:nodejs \u002Fapp\u002Fpackage.json .\u002F\n\nUSER appuser\nEXPOSE 3000\nENV NODE_ENV=production PORT=3000\n\n# Health check — orchestrators use this to know when app is ready\nHEALTHCHECK \\\n  --interval=30s \\\n  --timeout=10s \\\n  --start-period=40s \\\n  --retries=3 \\\n  CMD wget -qO- http:\u002F\u002Flocalhost:3000\u002Fhealth || exit 1\n\nENTRYPOINT [\"node\", \"dist\u002Fserver.js\"]\n```\n\n### Optimized Multi-Stage Dockerfile — Python\n```dockerfile\n# ─── Stage 1: Build dependencies ─────────────────────────────────────────────\nFROM python:3.12-slim AS builder\nWORKDIR \u002Fapp\n\nRUN pip install --upgrade pip\nCOPY requirements.txt .\nRUN pip install --prefix=\u002Finstall --no-cache-dir -r requirements.txt\n\n# ─── Stage 2: Production image ───────────────────────────────────────────────\nFROM python:3.12-slim AS runner\nWORKDIR \u002Fapp\n\n# Non-root user\nRUN useradd --system --uid 1001 --no-create-home appuser\n\n# Copy installed packages from builder\nCOPY --from=builder \u002Finstall \u002Fusr\u002Flocal\n\nCOPY --chown=appuser:appuser . .\n\nUSER appuser\nEXPOSE 8000\n\nHEALTHCHECK --interval=30s --timeout=10s --retries=3 \\\n  CMD python -c \"import urllib.request; urllib.request.urlopen('http:\u002F\u002Flocalhost:8000\u002Fhealth')\"\n\nCMD [\"python\", \"-m\", \"uvicorn\", \"main:app\", \"--host\", \"0.0.0.0\", \"--port\", \"8000\"]\n```\n\n### Optimized Multi-Stage Dockerfile — Go\n```dockerfile\n# ─── Stage 1: Build ──────────────────────────────────────────────────────────\nFROM golang:1.22-alpine AS builder\nWORKDIR \u002Fapp\n\n# Download dependencies first (cached layer)\nCOPY go.mod go.sum .\u002F\nRUN go mod download\n\nCOPY . .\n\n# Build static binary — no external dependencies\nRUN CGO_ENABLED=0 GOOS=linux go build \\\n    -ldflags=\"-w -s\" \\\n    -o server .\u002Fcmd\u002Fserver\n\n# ─── Stage 2: Minimal production image ───────────────────────────────────────\n# distroless: no shell, no package manager — smallest attack surface\nFROM gcr.io\u002Fdistroless\u002Fstatic-debian12 AS runner\n\nCOPY --from=builder \u002Fapp\u002Fserver \u002Fserver\n\nEXPOSE 8080\nUSER nonroot:nonroot\n\nENTRYPOINT [\"\u002Fserver\"]\n```\n\n### .dockerignore — Always Create This\n```\n# Version control\n.git\n.gitignore\n\n# Dependencies (always reinstalled in container)\nnode_modules\nvendor\n__pycache__\n*.pyc\n.venv\nvenv\n\n# Build artifacts\ndist\nbuild\n.next\nout\ntarget\n\n# Test & coverage\ncoverage\n*.test\n.pytest_cache\n__tests__\n\n# Environment files — NEVER include these\n.env\n.env.*\n*.env\n\n# Logs\n*.log\nlogs\n\n# Editor\n.vscode\n.idea\n*.swp\n*.swo\n\n# Docker files themselves\ndocker-compose*.yml\nDockerfile*\n\n# Docs\nREADME.md\nCHANGELOG.md\ndocs\n```\n\n### docker-compose — Production Pattern\n```yaml\nversion: \"3.9\"\n\nservices:\n  api:\n    build:\n      context: .\n      target: runner        # use specific build stage\n      cache_from:\n        - type=registry,ref=myregistry\u002Fmyapp:cache\n    image: myregistry\u002Fmyapp:${TAG:-latest}\n    ports:\n      - \"3000:3000\"\n    environment:\n      NODE_ENV: production\n      DATABASE_URL: postgresql:\u002F\u002Fuser:pass@db:5432\u002Fmydb\n      REDIS_URL: redis:\u002F\u002Fcache:6379\n    depends_on:\n      db:\n        condition: service_healthy\n      cache:\n        condition: service_healthy\n    restart: unless-stopped\n    deploy:\n      resources:\n        limits:\n          memory: 512M\n          cpus: \"0.5\"\n        reservations:\n          memory: 256M\n    read_only: true           # security: read-only filesystem\n    tmpfs:\n      - \u002Ftmp                  # writable temp dir\n    networks:\n      - app-net\n    logging:\n      driver: \"json-file\"\n      options:\n        max-size: \"10m\"\n        max-file: \"3\"\n\n  db:\n    image: postgres:16-alpine\n    environment:\n      POSTGRES_DB: mydb\n      POSTGRES_USER: user\n      POSTGRES_PASSWORD_FILE: \u002Frun\u002Fsecrets\u002Fdb_password\n    secrets:\n      - db_password\n    volumes:\n      - pgdata:\u002Fvar\u002Flib\u002Fpostgresql\u002Fdata\n      - .\u002Finit.sql:\u002Fdocker-entrypoint-initdb.d\u002Finit.sql:ro\n    healthcheck:\n      test: [\"CMD-SHELL\", \"pg_isready -U user -d mydb\"]\n      interval: 10s\n      timeout: 5s\n      retries: 5\n      start_period: 30s\n    restart: unless-stopped\n    networks:\n      - app-net\n\n  cache:\n    image: redis:7-alpine\n    command: redis-server --maxmemory 256mb --maxmemory-policy allkeys-lru\n    healthcheck:\n      test: [\"CMD\", \"redis-cli\", \"ping\"]\n      interval: 10s\n      timeout: 5s\n      retries: 5\n    restart: unless-stopped\n    networks:\n      - app-net\n\n  nginx:\n    image: nginx:alpine\n    ports:\n      - \"80:80\"\n      - \"443:443\"\n    volumes:\n      - .\u002Fnginx.conf:\u002Fetc\u002Fnginx\u002Fnginx.conf:ro\n      - .\u002Fcerts:\u002Fetc\u002Fnginx\u002Fcerts:ro\n    depends_on:\n      - api\n    restart: unless-stopped\n    networks:\n      - app-net\n\nvolumes:\n  pgdata:\n    driver: local\n\nnetworks:\n  app-net:\n    driver: bridge\n\nsecrets:\n  db_password:\n    file: .\u002Fsecrets\u002Fdb_password.txt\n```\n\n### docker-compose Override for Development\n```yaml\n# docker-compose.override.yml — auto-loaded in development\nversion: \"3.9\"\n\nservices:\n  api:\n    build:\n      target: builder       # use dev stage with devDependencies\n    volumes:\n      - .:\u002Fapp              # bind mount source for hot reload\n      - \u002Fapp\u002Fnode_modules   # anonymous volume to preserve container's node_modules\n    environment:\n      NODE_ENV: development\n      DEBUG: \"*\"\n    command: npm run dev    # override production command\n    ports:\n      - \"9229:9229\"         # Node.js debugger port\n\n  db:\n    ports:\n      - \"5432:5432\"         # expose for local tools like pgAdmin\n\n  cache:\n    ports:\n      - \"6379:6379\"         # expose for local Redis tools\n```\n\n### Networking Patterns\n```bash\n# Containers on same network communicate by service name\n# api → db:5432 (service name = hostname)\n# api → cache:6379\n\n# Inspect container network\ndocker inspect mycontainer | jq '.[0].NetworkSettings.Networks'\n\n# Connect running container to another network\ndocker network connect my-network my-container\n\n# Create custom network with specific subnet\ndocker network create \\\n  --driver bridge \\\n  --subnet 172.20.0.0\u002F16 \\\n  --ip-range 172.20.240.0\u002F20 \\\n  my-custom-net\n\n# List all networks\ndocker network ls\n\n# Remove unused networks\ndocker network prune\n```\n\n### Debugging Commands\n```bash\n# Get interactive shell in running container\ndocker exec -it \u003Ccontainer_name> sh\n\n# Debug a stopped or crashing container\n# Override entrypoint to get shell\ndocker run --rm -it --entrypoint sh myimage:latest\n\n# Follow logs with timestamps\ndocker logs -f --timestamps --tail=100 \u003Ccontainer_name>\n\n# Copy files out of container for inspection\ndocker cp \u003Ccontainer_name>:\u002Fapp\u002Flogs\u002Ferror.log .\u002Ferror.log\n\n# Real-time resource usage\ndocker stats --no-stream\n\n# Inspect everything about a container\ndocker inspect \u003Ccontainer_name>\n\n# View image layers and sizes\ndocker history myimage:latest --human --no-trunc\n\n# Check what changed in container filesystem vs image\ndocker diff \u003Ccontainer_name>\n\n# Scan image for vulnerabilities\ndocker scout cves myimage:latest\n\n# Build with detailed output for debugging cache\ndocker build --progress=plain --no-cache .\n\n# Check why container exited\ndocker inspect \u003Ccontainer_name> | jq '.[0].State'\n```\n\n### Multi-Arch Build with Buildx\n```bash\n# Create and use a buildx builder\ndocker buildx create --name mybuilder --use\ndocker buildx inspect --bootstrap\n\n# Build for multiple architectures and push\ndocker buildx build \\\n  --platform linux\u002Famd64,linux\u002Farm64 \\\n  --tag myregistry\u002Fmyapp:latest \\\n  --push \\\n  .\n\n# Build with cache export to registry\ndocker buildx build \\\n  --cache-from type=registry,ref=myregistry\u002Fmyapp:cache \\\n  --cache-to type=registry,ref=myregistry\u002Fmyapp:cache,mode=max \\\n  --tag myregistry\u002Fmyapp:latest \\\n  --push \\\n  .\n```\n\n### Health Check Patterns\n```dockerfile\n# HTTP health check\nHEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \\\n  CMD wget -qO- http:\u002F\u002Flocalhost:3000\u002Fhealth || exit 1\n\n# TCP health check (when no HTTP endpoint)\nHEALTHCHECK --interval=10s --timeout=5s --retries=5 \\\n  CMD nc -z localhost 5432 || exit 1\n\n# Custom script health check\nCOPY healthcheck.sh \u002Fhealthcheck.sh\nRUN chmod +x \u002Fhealthcheck.sh\nHEALTHCHECK --interval=30s CMD \u002Fhealthcheck.sh\n```\n\n---\n\n## Best Practices\n\n- Always use specific image tags — never `latest` in production (`node:20-alpine` not `node:latest`)\n- Always create `.dockerignore` — dramatically speeds up builds and reduces context size\n- Run as non-root user in every production container\n- Use multi-stage builds — final image should contain only what is needed to run\n- Set memory and CPU limits — prevent one container from starving others\n- Add `HEALTHCHECK` to every production image\n- Use `read_only: true` + `tmpfs` for `\u002Ftmp` — better security posture\n- Never put secrets in `ENV` or `ARG` — use Docker secrets or secret mounts\n- Pin base image digests for reproducibility in critical systems\n- Use `dumb-init` or `tini` as PID 1 to handle signals properly\n\n---\n\n## Common Pitfalls\n\n| Pitfall | Problem | Fix |\n|---|---|---|\n| No `.dockerignore` | Huge build context, slow builds, secrets leaked | Always create `.dockerignore` |\n| Running as root | Security vulnerability | Add non-root user in Dockerfile |\n| Copy source before package.json | Cache busted on every code change | Copy package.json first, then source |\n| Secrets in `ENV` or `ARG` | Visible in `docker inspect` and image history | Use `--secret` mount or Docker secrets |\n| No health check | Orchestrator cannot detect unhealthy app | Add `HEALTHCHECK` instruction |\n| `latest` tag | Non-deterministic, impossible to rollback | Always pin exact version tags |\n| One huge RUN command | Hard to debug layer failures | Split logical steps into separate RUN |\n| No resource limits | One container can OOM the host | Always set memory limits in production |\n\n---\n\n## Related Skills\n\n- **kubernetes-expert**: For orchestrating containers at scale\n- **cicd-expert**: For Docker in CI\u002FCD pipelines\n- **nginx-expert**: For Nginx as a reverse proxy in containers\n- **linux-expert**: For Linux container internals\n- **aws-expert**: For ECR, ECS, and EKS on AWS\n",{"name":5,"author":44,"license":15,"metadata":45,"description":7},"luo-kai",{"author":9,"version":46,"category":47},"1.0","coding","main","4d2fb89cdfb75f3f6fd3c6c5ec9ad90ea129eb3c","ai-agent-skills\u002F05-devops-and-cloud (by Luo Kai)\u002F05-docker-containers\u002Fdocker-expert",2,"https:\u002F\u002Fgithub.com\u002Fluokai0\u002Fai-agent-skills-by-luo-kai","https:\u002F\u002Fgithub.com\u002Fluokai0","a solo builder.","2026-05-06 04:29:04",{"source":8,"skillName":5,"commands":57,"prompt":67,"zipAvailable":68},[58,61,64],{"tool":59,"command":60},"npx","npx skills add luokai0\u002Fai-agent-skills-by-luo-kai --skill docker-expert",{"tool":62,"command":63},"bunx","bunx skills add luokai0\u002Fai-agent-skills-by-luo-kai --skill docker-expert",{"tool":65,"command":66},"pnpm","pnpm dlx skills add luokai0\u002Fai-agent-skills-by-luo-kai --skill docker-expert","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fluokai0\u002Fai-agent-skills-by-luo-kai\u002Fblob\u002Fmain\u002Fai-agent-skills\u002F05-devops-and-cloud (by Luo Kai)\u002F05-docker-containers\u002Fdocker-expert\u002FSKILL.md",true,[],[71,98,115,139,165,190],{"skillNo":72,"name":73,"nameZh":6,"description":74,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":75,"categories":76,"keywords":77,"publishedAt":39},"01M6F2SKTE208174C7S7JJCZC7","write-contracts","Generates secure Aptos Move V2 smart contracts with Object model, Digital Asset integration, security patterns, and storage type guidance. Includes comprehensive storage decision framework for optimal data structure selection. Triggers on: 'write contract', 'create NFT collection', 'build marketplace', 'implement minting', 'generate Move module', 'create token contract', 'build DAO', 'implement staking'. Ask storage questions when: 'store', 'track', 'registry', 'mapping', 'list', 'collection'.","https:\u002F\u002Fgithub.com\u002Fluokai0\u002Fai-agent-skills-by-luo-kai\u002Fblob\u002Fmain\u002Fai-agent-skills\u002F22-clawhub-skills\u002Fwrite-contracts\u002FSKILL.md",[],[78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97],"write","contracts","write contracts","storage","secure","create","generate","collection","model","decision","ask","smart-contracts","selection","objects","structure","nft","token","aptos","critical","move",{"skillNo":99,"name":100,"nameZh":6,"description":101,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":102,"categories":103,"keywords":104,"publishedAt":39},"01M6F2RFXJ6T9MKW0A7N7GM45B","web-search","通用网络搜索技能，支持多引擎搜索（百度、必应、DuckDuckGo），无需API密钥即可获取实时信息","https:\u002F\u002Fgithub.com\u002Fluokai0\u002Fai-agent-skills-by-luo-kai\u002Fblob\u002Fmain\u002Fai-agent-skills\u002F22-clawhub-skills\u002Fweb-search-ex-skill\u002FSKILL.md",[],[105,106,107,108,109,110,111,112,113,114],"web","search","web search","搜索","baidu","bing","duckduckgo","百度","多引擎","internet",{"skillNo":116,"name":117,"nameZh":6,"description":118,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":119,"categories":120,"keywords":121,"publishedAt":39},"01M6F2K968G1FZEZFPW2E6B222","solo-build","Execute implementation plan tasks with TDD workflow, auto-commit, and phase gates. Use when user says \"build it\", \"start building\", \"execute plan\", \"implement tasks\", \"ship it\", or references a track ID. Do NOT use for planning (use \u002Fplan) or scaffolding (use \u002Fscaffold).","https:\u002F\u002Fgithub.com\u002Fluokai0\u002Fai-agent-skills-by-luo-kai\u002Fblob\u002Fmain\u002Fai-agent-skills\u002F22-clawhub-skills\u002Fsolo-build\u002FSKILL.md",[],[25,122,123,124,125,126,127,128,106,129,130,131,78,132,133,134,135,136,137,138],"solo","solo build","MCP","workflow","commit","tasks","code","Bash","plan","read","auto","references","context7","query","scaffolding","ship it","project",{"skillNo":140,"name":141,"nameZh":6,"description":142,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":143,"categories":144,"keywords":145,"publishedAt":39},"01M6F2GKN39SGHSPWYB3662YC8","react-email","Use when building HTML email templates with React components, adding a visual email editor to an application using the React Email visual editor, rendering emails to HTML, or sending emails with Resend. Covers welcome emails, password resets, notifications, order confirmations, newsletters, transactional emails, and the embeddable email editor component.","https:\u002F\u002Fgithub.com\u002Fluokai0\u002Fai-agent-skills-by-luo-kai\u002Fblob\u002Fmain\u002Fai-agent-skills\u002F22-clawhub-skills\u002Freact-email-skills\u002FSKILL.md",[],[146,147,148,149,150,151,152,153,154,155,156,157,158,30,159,160,161,162,163,164],"react","email","react email","github","editor","components","react components","component","welcome","https","notifications","password","node","html","resend","visual","emails","rendering","with",{"skillNo":166,"name":167,"nameZh":6,"description":168,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":169,"categories":170,"keywords":171,"publishedAt":39},"01M6F2FBVGVDFSG8SSFJGXA40C","APITester Agent-Driven API Testing","Test API endpoints and document responses. Define tests in plain English, run them, get formatted results. Agent-driven Postman alternative.","https:\u002F\u002Fgithub.com\u002Fluokai0\u002Fai-agent-skills-by-luo-kai\u002Fblob\u002Fmain\u002Fai-agent-skills\u002F22-clawhub-skills\u002Fopenclaw-api-tester\u002FSKILL.md",[],[172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189],"testing","api","api testing","driven","APITester Agent Driven API Testing","test","run","postman","results","plain english","tester","endpoints","document","get","define","tests","english","api-tester",{"skillNo":191,"name":192,"nameZh":6,"description":193,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":194,"categories":195,"keywords":196,"publishedAt":39},"01M6F273Y3NGAPVJZ608BC0G9G","hubspot-implementation-plan","Generate a phased implementation plan from a HubSpot audit report. Creates prioritized, sequenced cleanup processes with effort estimates, dependencies, and automation feasibility. Use after running \u002Fhubspot-audit.","https:\u002F\u002Fgithub.com\u002Fluokai0\u002Fai-agent-skills-by-luo-kai\u002Fblob\u002Fmain\u002Fai-agent-skills\u002F22-clawhub-skills\u002Fhubspot-implementation-plan\u002FSKILL.md",[],[130,197,198,199,200,201,202,84,203,204,205,206,207,30,208,209,164,210],"implementation","hubspot","hubspot implementation plan","automation","feasibility","cleanup","planning","report","audit","audit report","phased implementation","dependencies","processes","hubspot audit"]