[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7DAYEFK80TE5XFJX7329VT3":3,"skill-same:01M7DAYEFK80TE5XFJX7329VT3":44},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":18,"linkOnly":19,"markdownContent":20,"markdownBody":21,"frontMatter":22,"refName":23,"commitSha":24,"skillDirectory":25,"forksCount":26,"repositoryHtmlUrl":27,"repositoryHomepageUrl":6,"ownerHtmlUrl":28,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":29,"install":30,"resources":43},"01M7DAYEFK80TE5XFJX7329VT3","docker-patterns",null,"Docker and Docker Compose patterns for local development, hardened CLI installer harnesses, container security, networking, volumes, and multi-service orchestration. Use when creating or reviewing Dockerfiles and Compose services, testing installers across Linux distributions, or planning accurate native macOS and Windows validation.","MoradDev\u002Fskills-unified","MoradDev","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F72839584?v=4","01M7DASN3HYHFBYW4ZNMPTHQ63","01M7DASN4N6P4P9WMEFRE2V0TF",2,"MIT","https:\u002F\u002Fgithub.com\u002FMoradDev\u002Fskills-unified\u002Fblob\u002Fmain\u002Fcuration\u002Fskills\u002Fdocker-patterns\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: docker-patterns\ndescription: Docker and Docker Compose patterns for local development, hardened CLI installer harnesses, container security, networking, volumes, and multi-service orchestration. Use when creating or reviewing Dockerfiles and Compose services, testing installers across Linux distributions, or planning accurate native macOS and Windows validation.\n---\n\n# Docker Patterns\n\nDocker and Docker Compose best practices for containerized development.\n\n## Docker Compose for Local Development\n\n### Standard Web App Stack\n\n```yaml\n# docker-compose.yml\nservices:\n  app:\n    build:\n      context: .\n      target: dev                     # Use dev stage of multi-stage Dockerfile\n    ports:\n      - \"3000:3000\"\n    volumes:\n      - .:\u002Fapp                        # Bind mount for hot reload\n      - \u002Fapp\u002Fnode_modules             # Anonymous volume -- preserves container deps\n    environment:\n      - DATABASE_URL=postgres:\u002F\u002Fpostgres:postgres@db:5432\u002Fapp_dev\n      - REDIS_URL=redis:\u002F\u002Fredis:6379\u002F0\n      - NODE_ENV=development\n    depends_on:\n      db:\n        condition: service_healthy\n      redis:\n        condition: service_started\n    command: npm run dev\n\n  db:\n    image: postgres:16-alpine\n    ports:\n      - \"5432:5432\"\n    environment:\n      POSTGRES_USER: postgres\n      POSTGRES_PASSWORD: postgres\n      POSTGRES_DB: app_dev\n    volumes:\n      - pgdata:\u002Fvar\u002Flib\u002Fpostgresql\u002Fdata\n      - .\u002Fscripts\u002Finit-db.sql:\u002Fdocker-entrypoint-initdb.d\u002Finit.sql\n    healthcheck:\n      test: [\"CMD-SHELL\", \"pg_isready -U postgres\"]\n      interval: 5s\n      timeout: 3s\n      retries: 5\n\n  redis:\n    image: redis:7-alpine\n    ports:\n      - \"6379:6379\"\n    volumes:\n      - redisdata:\u002Fdata\n\n  mailpit:                            # Local email testing\n    image: axllent\u002Fmailpit\n    ports:\n      - \"8025:8025\"                   # Web UI\n      - \"1025:1025\"                   # SMTP\n\nvolumes:\n  pgdata:\n  redisdata:\n```\n\n### Development vs Production Dockerfile\n\n```dockerfile\n# Stage: dependencies\nFROM node:22-alpine AS deps\nWORKDIR \u002Fapp\nCOPY package.json package-lock.json .\u002F\nRUN npm ci\n\n# Stage: dev (hot reload, debug tools)\nFROM node:22-alpine AS dev\nWORKDIR \u002Fapp\nCOPY --from=deps \u002Fapp\u002Fnode_modules .\u002Fnode_modules\nCOPY . .\nEXPOSE 3000\nCMD [\"npm\", \"run\", \"dev\"]\n\n# Stage: build\nFROM node:22-alpine AS build\nWORKDIR \u002Fapp\nCOPY --from=deps \u002Fapp\u002Fnode_modules .\u002Fnode_modules\nCOPY . .\nRUN npm run build && npm prune --production\n\n# Stage: production (minimal image)\nFROM node:22-alpine AS production\nWORKDIR \u002Fapp\nRUN addgroup -g 1001 -S appgroup && adduser -S appuser -u 1001\nUSER appuser\nCOPY --from=build --chown=appuser:appgroup \u002Fapp\u002Fdist .\u002Fdist\nCOPY --from=build --chown=appuser:appgroup \u002Fapp\u002Fnode_modules .\u002Fnode_modules\nCOPY --from=build --chown=appuser:appgroup \u002Fapp\u002Fpackage.json .\u002F\nENV NODE_ENV=production\nEXPOSE 3000\nHEALTHCHECK --interval=30s --timeout=3s CMD wget -qO- http:\u002F\u002Flocalhost:3000\u002Fhealth || exit 1\nCMD [\"node\", \"dist\u002Fserver.js\"]\n```\n\n### Override Files\n\n```yaml\n# docker-compose.override.yml (auto-loaded, dev-only settings)\nservices:\n  app:\n    environment:\n      - DEBUG=app:*\n      - LOG_LEVEL=debug\n    ports:\n      - \"9229:9229\"                   # Node.js debugger\n\n# docker-compose.prod.yml (explicit for production)\nservices:\n  app:\n    build:\n      target: production\n    restart: always\n    deploy:\n      resources:\n        limits:\n          cpus: \"1.0\"\n          memory: 512M\n```\n\n```bash\n# Development (auto-loads override)\ndocker compose up\n\n# Production\ndocker compose -f docker-compose.yml -f docker-compose.prod.yml up -d\n```\n\n## Networking\n\n### Service Discovery\n\nServices in the same Compose network resolve by service name:\n```\n# From \"app\" container:\npostgres:\u002F\u002Fpostgres:postgres@db:5432\u002Fapp_dev    # \"db\" resolves to the db container\nredis:\u002F\u002Fredis:6379\u002F0                             # \"redis\" resolves to the redis container\n```\n\n### Custom Networks\n\n```yaml\nservices:\n  frontend:\n    networks:\n      - frontend-net\n\n  api:\n    networks:\n      - frontend-net\n      - backend-net\n\n  db:\n    networks:\n      - backend-net              # Only reachable from api, not frontend\n\nnetworks:\n  frontend-net:\n  backend-net:\n```\n\n### Exposing Only What's Needed\n\n```yaml\nservices:\n  db:\n    ports:\n      - \"127.0.0.1:5432:5432\"   # Only accessible from host, not network\n    # Omit ports entirely in production -- accessible only within Docker network\n```\n\n## Volume Strategies\n\n```yaml\nvolumes:\n  # Named volume: persists across container restarts, managed by Docker\n  pgdata:\n\n  # Bind mount: maps host directory into container (for development)\n  # - .\u002Fsrc:\u002Fapp\u002Fsrc\n\n  # Anonymous volume: preserves container-generated content from bind mount override\n  # - \u002Fapp\u002Fnode_modules\n```\n\n### Common Patterns\n\n```yaml\nservices:\n  app:\n    volumes:\n      - .:\u002Fapp                   # Source code (bind mount for hot reload)\n      - \u002Fapp\u002Fnode_modules        # Protect container's node_modules from host\n      - \u002Fapp\u002F.next               # Protect build cache\n\n  db:\n    volumes:\n      - pgdata:\u002Fvar\u002Flib\u002Fpostgresql\u002Fdata          # Persistent data\n      - .\u002Fscripts\u002Finit.sql:\u002Fdocker-entrypoint-initdb.d\u002Finit.sql  # Init scripts\n```\n\n## Container Security\n\n### Dockerfile Hardening\n\n```dockerfile\n# 1. Use specific tags (never :latest)\nFROM node:22.12-alpine3.20\n\n# 2. Run as non-root\nRUN addgroup -g 1001 -S app && adduser -S app -u 1001\nUSER app\n\n# 3. Drop capabilities (in compose)\n# 4. Read-only root filesystem where possible\n# 5. No secrets in image layers\n```\n\n### Compose Security\n\n```yaml\nservices:\n  app:\n    security_opt:\n      - no-new-privileges:true\n    read_only: true\n    tmpfs:\n      - \u002Ftmp\n      - \u002Fapp\u002F.cache\n    cap_drop:\n      - ALL\n    cap_add:\n      - NET_BIND_SERVICE          # Only if binding to ports \u003C 1024\n```\n\n### Secret Management\n\n```yaml\n# GOOD: Use environment variables (injected at runtime)\nservices:\n  app:\n    env_file:\n      - .env                     # Never commit .env to git\n    environment:\n      - API_KEY                  # Inherits from host environment\n\n# GOOD: Docker secrets (Swarm mode)\nsecrets:\n  db_password:\n    file: .\u002Fsecrets\u002Fdb_password.txt\n\nservices:\n  db:\n    secrets:\n      - db_password\n\n# BAD: Hardcoded in image\n# ENV API_KEY=sk-proj-xxxxx      # NEVER DO THIS\n```\n\n## Hardened CLI Installer Harnesses\n\nUse containers to test installer behavior against disposable project copies without allowing the test to mutate the source checkout.\n\n### Respect the Platform Boundary\n\n- Run real containers for Linux distributions such as Debian and Ubuntu.\n- macOS cannot run as a Docker container because Docker shares a Linux kernel. Run the same shell-free test entry point natively on macOS.\n- Windows containers require a Windows Docker engine. Run platform-independent logic on a native Windows CI runner and reserve Windows containers for a Windows host.\n- Keep a native Ubuntu\u002FmacOS\u002FWindows CI matrix for host-specific paths, command shims, quoting, and filesystem behavior.\n\nDo not claim that a Linux container validates macOS or Windows behavior.\n\n### Enforce the Isolation Contract\n\n- Pin base images by immutable digest and pin installed CLI versions.\n- Run as a non-root numeric UID\u002FGID when distro account names differ.\n- Mount the repository and source project read-only.\n- Copy the source project into a writable `tmpfs` workspace before any mutation.\n- Mount `\u002Fworkspace` with `noexec`, UID\u002FGID 1000, and `mode=0700` so only the\n  container user can inspect project data.\n- Keep npm and npx's executable cache at `NPM_CONFIG_CACHE=\u002Ftmp\u002Fnpm-cache` on\n  the executable `\u002Ftmp` mount. Its default size is 2 GiB and can be adjusted\n  with `ECC_TMPFS_SIZE`; `ECC_WORKSPACE_SIZE` separately controls the private\n  workspace mount.\n- Set `read_only: true`, `no-new-privileges:true`, `cap_drop: [ALL]`, and a finite `pids_limit`.\n- Keep the default real-CLI services on `network_mode: none`. Add network access\n  only through a visibly named opt-in service for an authenticated provider\n  session; never make it an accidental environment-driven default.\n- Create only the writable temporary paths the tool needs.\n- Do not pass host credentials into the container by default.\n- Default to a dry run and whitelist only the explicit `dry-run`, `install`,\n  `plugin`, and `shell` modes.\n- Use argument arrays or `spawnSync(..., { shell: false })` for cross-platform runners. Never interpolate project paths into a shell command.\n\n### Exercise the ECC Plugin Setup Harness\n\nUse `docker\u002Fplugin-setup\u002Fcompose.yaml` as the reference implementation. It provides:\n\n- `fixture-tests` for the focused install manifest, target, and executor suite.\n- `real-cli` for the pinned Debian-based generic Linux image.\n- `real-cli-ubuntu` for the pinned Ubuntu image.\n\nValidate the Compose model before building:\n\n```bash\ndocker compose -f docker\u002Fplugin-setup\u002Fcompose.yaml config --quiet\n```\n\nBuild both real Linux images:\n\n```bash\ndocker compose -f docker\u002Fplugin-setup\u002Fcompose.yaml \\\n  build real-cli real-cli-ubuntu\n```\n\nRun the safe default flow in each image:\n\n```bash\ndocker compose -p ecc-plugin-debian-test \\\n  -f docker\u002Fplugin-setup\u002Fcompose.yaml \\\n  run --rm -T real-cli dry-run\n\ndocker compose -p ecc-plugin-ubuntu-test \\\n  -f docker\u002Fplugin-setup\u002Fcompose.yaml \\\n  run --rm -T real-cli-ubuntu dry-run\n```\n\nThe dry run executes the current public command contract:\n\n```bash\necc install --profile core --target claude-project --dry-run --json\n```\n\nBefore that command runs, the container creates a locally packed npm artifact\nfrom the read-only checkout with `npm pack --ignore-scripts`. It extracts the\nself-created tarball under `\u002Ftmp`, validates the `ecc-universal` package name,\nrequired install manifests, and the confined `package.json` `bin.ecc` mapping,\nthen invokes the extracted `ecc` executable. The runtime stays on\n`network_mode: none`, does not execute package lifecycle scripts, and does not\nrely on host `node_modules`; its exact pinned production dependencies are\nalready present in the image.\n\nThe harness rejects an empty plan, a non-`claude-project` target, any operation\noutside `\u002Fworkspace\u002Fproject\u002F.claude`, or any dry run that creates the target\ndirectory. `install` performs the isolated apply twice, checks its managed\ninstall state, lists the installed target, and runs `doctor`.\n\n### Start, Open, Reconnect, and Clean Up a Named Session\n\nStart a detached container without `--rm` so leaving a terminal does not remove\nthe session:\n\n```bash\ndocker compose -p ecc-plugin-session \\\n  -f docker\u002Fplugin-setup\u002Fcompose.yaml \\\n  run --detach --name ecc-plugin-shell real-cli shell\n```\n\nThe container copies the read-only fixture to the stable private directory\n`\u002Fworkspace\u002Fproject`. Confirm it is running, then emit the Docker side of the\nterminal-opener v1 data contract:\n\n```bash\ndocker inspect --format '{{.State.Running}}' ecc-plugin-shell\nnode docker\u002Fplugin-setup\u002Finteractive-plan.js \\\n  --container ecc-plugin-shell \\\n  --workdir \u002Fworkspace\u002Fproject \\\n  --json \\\n  -- bash\n```\n\nThe JSON result has exactly an `executable` and `argv` boundary (plus\n`contractVersion: 1`): the executable is `docker`, and argv begins with\n`exec`, `-it`, and `-w`. Pass that data to the separate terminal-opener skill\nwhen it is installed. This Docker harness deliberately does not import a\nterminal adapter, interpolate a shell command, or manage a host GUI process.\nUntil then, open the same PTY in the current host terminal directly:\n\n```bash\ndocker exec -it -w \u002Fworkspace\u002Fproject ecc-plugin-shell bash\n```\n\nExit the shell without stopping the detached container. Reconnect with the\nsame `docker exec -it` command. When finished, remove the exact named container\nand its Compose project resources:\n\n```bash\ndocker rm --force ecc-plugin-shell\ndocker compose -p ecc-plugin-session \\\n  -f docker\u002Fplugin-setup\u002Fcompose.yaml \\\n  down --remove-orphans\n```\n\nHost credentials are absent by default and credential directories are never\nmounted. The default service also has no network access. When an authenticated\nprovider session genuinely needs a network, build `real-cli` first and then opt\nin visibly with `docker compose --profile networked run real-cli-networked\nshell`. Prefer authenticating inside that disposable session. If a CI run must\ninherit a host environment credential, make that opt-in at invocation with an\nexplicit Compose `--env NAME` flag, understand that the value is inspectable\nand can be exfiltrated for the container lifetime, and remove the exact named\ncontainer immediately after.\n\nRun the same focused suite natively on the host:\n\n```bash\nnpm run test:plugin-setup-platform\n```\n\nInspect the produced identity and environment before trusting the image:\n\n```bash\ndocker image inspect ecc-plugin-setup:debian ecc-plugin-setup:ubuntu\n```\n\nClean each named test project without deleting unrelated volumes or images:\n\n```bash\ndocker compose -p ecc-plugin-debian-test \\\n  -f docker\u002Fplugin-setup\u002Fcompose.yaml down --remove-orphans\ndocker compose -p ecc-plugin-ubuntu-test \\\n  -f docker\u002Fplugin-setup\u002Fcompose.yaml down --remove-orphans\n```\n\n## .dockerignore\n\n```\nnode_modules\n.git\n.env\n.env.*\ndist\ncoverage\n*.log\n.next\n.cache\ndocker-compose*.yml\nDockerfile*\nREADME.md\ntests\u002F\n```\n\n## Debugging\n\n### Common Commands\n\n```bash\n# View logs\ndocker compose logs -f app           # Follow app logs\ndocker compose logs --tail=50 db     # Last 50 lines from db\n\n# Execute commands in running container\ndocker compose exec app sh           # Shell into app\ndocker compose exec db psql -U postgres  # Connect to postgres\n\n# Inspect\ndocker compose ps                     # Running services\ndocker compose top                    # Processes in each container\ndocker stats                          # Resource usage\n\n# Rebuild\ndocker compose up --build             # Rebuild images\ndocker compose build --no-cache app   # Force full rebuild\n\n# Clean up\ndocker compose down                   # Stop and remove containers\ndocker compose down -v                # Also remove volumes (DESTRUCTIVE)\ndocker system prune                   # Remove unused images\u002Fcontainers\n```\n\n### Debugging Network Issues\n\n```bash\n# Check DNS resolution inside container\ndocker compose exec app nslookup db\n\n# Check connectivity\ndocker compose exec app wget -qO- http:\u002F\u002Fapi:3000\u002Fhealth\n\n# Inspect network\ndocker network ls\ndocker network inspect \u003Cproject>_default\n```\n\n## Anti-Patterns\n\n```\n# BAD: Using docker compose in production without orchestration\n# Use Kubernetes, ECS, or Docker Swarm for production multi-container workloads\n\n# BAD: Storing data in containers without volumes\n# Containers are ephemeral -- all data lost on restart without volumes\n\n# BAD: Running as root\n# Always create and use a non-root user\n\n# BAD: Using :latest tag\n# Pin to specific versions for reproducible builds\n\n# BAD: One giant container with all services\n# Separate concerns: one process per container\n\n# BAD: Putting secrets in docker-compose.yml\n# Use .env files (gitignored) or Docker secrets\n```\n","# Docker Patterns\n\nDocker and Docker Compose best practices for containerized development.\n\n## Docker Compose for Local Development\n\n### Standard Web App Stack\n\n```yaml\n# docker-compose.yml\nservices:\n  app:\n    build:\n      context: .\n      target: dev                     # Use dev stage of multi-stage Dockerfile\n    ports:\n      - \"3000:3000\"\n    volumes:\n      - .:\u002Fapp                        # Bind mount for hot reload\n      - \u002Fapp\u002Fnode_modules             # Anonymous volume -- preserves container deps\n    environment:\n      - DATABASE_URL=postgres:\u002F\u002Fpostgres:postgres@db:5432\u002Fapp_dev\n      - REDIS_URL=redis:\u002F\u002Fredis:6379\u002F0\n      - NODE_ENV=development\n    depends_on:\n      db:\n        condition: service_healthy\n      redis:\n        condition: service_started\n    command: npm run dev\n\n  db:\n    image: postgres:16-alpine\n    ports:\n      - \"5432:5432\"\n    environment:\n      POSTGRES_USER: postgres\n      POSTGRES_PASSWORD: postgres\n      POSTGRES_DB: app_dev\n    volumes:\n      - pgdata:\u002Fvar\u002Flib\u002Fpostgresql\u002Fdata\n      - .\u002Fscripts\u002Finit-db.sql:\u002Fdocker-entrypoint-initdb.d\u002Finit.sql\n    healthcheck:\n      test: [\"CMD-SHELL\", \"pg_isready -U postgres\"]\n      interval: 5s\n      timeout: 3s\n      retries: 5\n\n  redis:\n    image: redis:7-alpine\n    ports:\n      - \"6379:6379\"\n    volumes:\n      - redisdata:\u002Fdata\n\n  mailpit:                            # Local email testing\n    image: axllent\u002Fmailpit\n    ports:\n      - \"8025:8025\"                   # Web UI\n      - \"1025:1025\"                   # SMTP\n\nvolumes:\n  pgdata:\n  redisdata:\n```\n\n### Development vs Production Dockerfile\n\n```dockerfile\n# Stage: dependencies\nFROM node:22-alpine AS deps\nWORKDIR \u002Fapp\nCOPY package.json package-lock.json .\u002F\nRUN npm ci\n\n# Stage: dev (hot reload, debug tools)\nFROM node:22-alpine AS dev\nWORKDIR \u002Fapp\nCOPY --from=deps \u002Fapp\u002Fnode_modules .\u002Fnode_modules\nCOPY . .\nEXPOSE 3000\nCMD [\"npm\", \"run\", \"dev\"]\n\n# Stage: build\nFROM node:22-alpine AS build\nWORKDIR \u002Fapp\nCOPY --from=deps \u002Fapp\u002Fnode_modules .\u002Fnode_modules\nCOPY . .\nRUN npm run build && npm prune --production\n\n# Stage: production (minimal image)\nFROM node:22-alpine AS production\nWORKDIR \u002Fapp\nRUN addgroup -g 1001 -S appgroup && adduser -S appuser -u 1001\nUSER appuser\nCOPY --from=build --chown=appuser:appgroup \u002Fapp\u002Fdist .\u002Fdist\nCOPY --from=build --chown=appuser:appgroup \u002Fapp\u002Fnode_modules .\u002Fnode_modules\nCOPY --from=build --chown=appuser:appgroup \u002Fapp\u002Fpackage.json .\u002F\nENV NODE_ENV=production\nEXPOSE 3000\nHEALTHCHECK --interval=30s --timeout=3s CMD wget -qO- http:\u002F\u002Flocalhost:3000\u002Fhealth || exit 1\nCMD [\"node\", \"dist\u002Fserver.js\"]\n```\n\n### Override Files\n\n```yaml\n# docker-compose.override.yml (auto-loaded, dev-only settings)\nservices:\n  app:\n    environment:\n      - DEBUG=app:*\n      - LOG_LEVEL=debug\n    ports:\n      - \"9229:9229\"                   # Node.js debugger\n\n# docker-compose.prod.yml (explicit for production)\nservices:\n  app:\n    build:\n      target: production\n    restart: always\n    deploy:\n      resources:\n        limits:\n          cpus: \"1.0\"\n          memory: 512M\n```\n\n```bash\n# Development (auto-loads override)\ndocker compose up\n\n# Production\ndocker compose -f docker-compose.yml -f docker-compose.prod.yml up -d\n```\n\n## Networking\n\n### Service Discovery\n\nServices in the same Compose network resolve by service name:\n```\n# From \"app\" container:\npostgres:\u002F\u002Fpostgres:postgres@db:5432\u002Fapp_dev    # \"db\" resolves to the db container\nredis:\u002F\u002Fredis:6379\u002F0                             # \"redis\" resolves to the redis container\n```\n\n### Custom Networks\n\n```yaml\nservices:\n  frontend:\n    networks:\n      - frontend-net\n\n  api:\n    networks:\n      - frontend-net\n      - backend-net\n\n  db:\n    networks:\n      - backend-net              # Only reachable from api, not frontend\n\nnetworks:\n  frontend-net:\n  backend-net:\n```\n\n### Exposing Only What's Needed\n\n```yaml\nservices:\n  db:\n    ports:\n      - \"127.0.0.1:5432:5432\"   # Only accessible from host, not network\n    # Omit ports entirely in production -- accessible only within Docker network\n```\n\n## Volume Strategies\n\n```yaml\nvolumes:\n  # Named volume: persists across container restarts, managed by Docker\n  pgdata:\n\n  # Bind mount: maps host directory into container (for development)\n  # - .\u002Fsrc:\u002Fapp\u002Fsrc\n\n  # Anonymous volume: preserves container-generated content from bind mount override\n  # - \u002Fapp\u002Fnode_modules\n```\n\n### Common Patterns\n\n```yaml\nservices:\n  app:\n    volumes:\n      - .:\u002Fapp                   # Source code (bind mount for hot reload)\n      - \u002Fapp\u002Fnode_modules        # Protect container's node_modules from host\n      - \u002Fapp\u002F.next               # Protect build cache\n\n  db:\n    volumes:\n      - pgdata:\u002Fvar\u002Flib\u002Fpostgresql\u002Fdata          # Persistent data\n      - .\u002Fscripts\u002Finit.sql:\u002Fdocker-entrypoint-initdb.d\u002Finit.sql  # Init scripts\n```\n\n## Container Security\n\n### Dockerfile Hardening\n\n```dockerfile\n# 1. Use specific tags (never :latest)\nFROM node:22.12-alpine3.20\n\n# 2. Run as non-root\nRUN addgroup -g 1001 -S app && adduser -S app -u 1001\nUSER app\n\n# 3. Drop capabilities (in compose)\n# 4. Read-only root filesystem where possible\n# 5. No secrets in image layers\n```\n\n### Compose Security\n\n```yaml\nservices:\n  app:\n    security_opt:\n      - no-new-privileges:true\n    read_only: true\n    tmpfs:\n      - \u002Ftmp\n      - \u002Fapp\u002F.cache\n    cap_drop:\n      - ALL\n    cap_add:\n      - NET_BIND_SERVICE          # Only if binding to ports \u003C 1024\n```\n\n### Secret Management\n\n```yaml\n# GOOD: Use environment variables (injected at runtime)\nservices:\n  app:\n    env_file:\n      - .env                     # Never commit .env to git\n    environment:\n      - API_KEY                  # Inherits from host environment\n\n# GOOD: Docker secrets (Swarm mode)\nsecrets:\n  db_password:\n    file: .\u002Fsecrets\u002Fdb_password.txt\n\nservices:\n  db:\n    secrets:\n      - db_password\n\n# BAD: Hardcoded in image\n# ENV API_KEY=sk-proj-xxxxx      # NEVER DO THIS\n```\n\n## Hardened CLI Installer Harnesses\n\nUse containers to test installer behavior against disposable project copies without allowing the test to mutate the source checkout.\n\n### Respect the Platform Boundary\n\n- Run real containers for Linux distributions such as Debian and Ubuntu.\n- macOS cannot run as a Docker container because Docker shares a Linux kernel. Run the same shell-free test entry point natively on macOS.\n- Windows containers require a Windows Docker engine. Run platform-independent logic on a native Windows CI runner and reserve Windows containers for a Windows host.\n- Keep a native Ubuntu\u002FmacOS\u002FWindows CI matrix for host-specific paths, command shims, quoting, and filesystem behavior.\n\nDo not claim that a Linux container validates macOS or Windows behavior.\n\n### Enforce the Isolation Contract\n\n- Pin base images by immutable digest and pin installed CLI versions.\n- Run as a non-root numeric UID\u002FGID when distro account names differ.\n- Mount the repository and source project read-only.\n- Copy the source project into a writable `tmpfs` workspace before any mutation.\n- Mount `\u002Fworkspace` with `noexec`, UID\u002FGID 1000, and `mode=0700` so only the\n  container user can inspect project data.\n- Keep npm and npx's executable cache at `NPM_CONFIG_CACHE=\u002Ftmp\u002Fnpm-cache` on\n  the executable `\u002Ftmp` mount. Its default size is 2 GiB and can be adjusted\n  with `ECC_TMPFS_SIZE`; `ECC_WORKSPACE_SIZE` separately controls the private\n  workspace mount.\n- Set `read_only: true`, `no-new-privileges:true`, `cap_drop: [ALL]`, and a finite `pids_limit`.\n- Keep the default real-CLI services on `network_mode: none`. Add network access\n  only through a visibly named opt-in service for an authenticated provider\n  session; never make it an accidental environment-driven default.\n- Create only the writable temporary paths the tool needs.\n- Do not pass host credentials into the container by default.\n- Default to a dry run and whitelist only the explicit `dry-run`, `install`,\n  `plugin`, and `shell` modes.\n- Use argument arrays or `spawnSync(..., { shell: false })` for cross-platform runners. Never interpolate project paths into a shell command.\n\n### Exercise the ECC Plugin Setup Harness\n\nUse `docker\u002Fplugin-setup\u002Fcompose.yaml` as the reference implementation. It provides:\n\n- `fixture-tests` for the focused install manifest, target, and executor suite.\n- `real-cli` for the pinned Debian-based generic Linux image.\n- `real-cli-ubuntu` for the pinned Ubuntu image.\n\nValidate the Compose model before building:\n\n```bash\ndocker compose -f docker\u002Fplugin-setup\u002Fcompose.yaml config --quiet\n```\n\nBuild both real Linux images:\n\n```bash\ndocker compose -f docker\u002Fplugin-setup\u002Fcompose.yaml \\\n  build real-cli real-cli-ubuntu\n```\n\nRun the safe default flow in each image:\n\n```bash\ndocker compose -p ecc-plugin-debian-test \\\n  -f docker\u002Fplugin-setup\u002Fcompose.yaml \\\n  run --rm -T real-cli dry-run\n\ndocker compose -p ecc-plugin-ubuntu-test \\\n  -f docker\u002Fplugin-setup\u002Fcompose.yaml \\\n  run --rm -T real-cli-ubuntu dry-run\n```\n\nThe dry run executes the current public command contract:\n\n```bash\necc install --profile core --target claude-project --dry-run --json\n```\n\nBefore that command runs, the container creates a locally packed npm artifact\nfrom the read-only checkout with `npm pack --ignore-scripts`. It extracts the\nself-created tarball under `\u002Ftmp`, validates the `ecc-universal` package name,\nrequired install manifests, and the confined `package.json` `bin.ecc` mapping,\nthen invokes the extracted `ecc` executable. The runtime stays on\n`network_mode: none`, does not execute package lifecycle scripts, and does not\nrely on host `node_modules`; its exact pinned production dependencies are\nalready present in the image.\n\nThe harness rejects an empty plan, a non-`claude-project` target, any operation\noutside `\u002Fworkspace\u002Fproject\u002F.claude`, or any dry run that creates the target\ndirectory. `install` performs the isolated apply twice, checks its managed\ninstall state, lists the installed target, and runs `doctor`.\n\n### Start, Open, Reconnect, and Clean Up a Named Session\n\nStart a detached container without `--rm` so leaving a terminal does not remove\nthe session:\n\n```bash\ndocker compose -p ecc-plugin-session \\\n  -f docker\u002Fplugin-setup\u002Fcompose.yaml \\\n  run --detach --name ecc-plugin-shell real-cli shell\n```\n\nThe container copies the read-only fixture to the stable private directory\n`\u002Fworkspace\u002Fproject`. Confirm it is running, then emit the Docker side of the\nterminal-opener v1 data contract:\n\n```bash\ndocker inspect --format '{{.State.Running}}' ecc-plugin-shell\nnode docker\u002Fplugin-setup\u002Finteractive-plan.js \\\n  --container ecc-plugin-shell \\\n  --workdir \u002Fworkspace\u002Fproject \\\n  --json \\\n  -- bash\n```\n\nThe JSON result has exactly an `executable` and `argv` boundary (plus\n`contractVersion: 1`): the executable is `docker`, and argv begins with\n`exec`, `-it`, and `-w`. Pass that data to the separate terminal-opener skill\nwhen it is installed. This Docker harness deliberately does not import a\nterminal adapter, interpolate a shell command, or manage a host GUI process.\nUntil then, open the same PTY in the current host terminal directly:\n\n```bash\ndocker exec -it -w \u002Fworkspace\u002Fproject ecc-plugin-shell bash\n```\n\nExit the shell without stopping the detached container. Reconnect with the\nsame `docker exec -it` command. When finished, remove the exact named container\nand its Compose project resources:\n\n```bash\ndocker rm --force ecc-plugin-shell\ndocker compose -p ecc-plugin-session \\\n  -f docker\u002Fplugin-setup\u002Fcompose.yaml \\\n  down --remove-orphans\n```\n\nHost credentials are absent by default and credential directories are never\nmounted. The default service also has no network access. When an authenticated\nprovider session genuinely needs a network, build `real-cli` first and then opt\nin visibly with `docker compose --profile networked run real-cli-networked\nshell`. Prefer authenticating inside that disposable session. If a CI run must\ninherit a host environment credential, make that opt-in at invocation with an\nexplicit Compose `--env NAME` flag, understand that the value is inspectable\nand can be exfiltrated for the container lifetime, and remove the exact named\ncontainer immediately after.\n\nRun the same focused suite natively on the host:\n\n```bash\nnpm run test:plugin-setup-platform\n```\n\nInspect the produced identity and environment before trusting the image:\n\n```bash\ndocker image inspect ecc-plugin-setup:debian ecc-plugin-setup:ubuntu\n```\n\nClean each named test project without deleting unrelated volumes or images:\n\n```bash\ndocker compose -p ecc-plugin-debian-test \\\n  -f docker\u002Fplugin-setup\u002Fcompose.yaml down --remove-orphans\ndocker compose -p ecc-plugin-ubuntu-test \\\n  -f docker\u002Fplugin-setup\u002Fcompose.yaml down --remove-orphans\n```\n\n## .dockerignore\n\n```\nnode_modules\n.git\n.env\n.env.*\ndist\ncoverage\n*.log\n.next\n.cache\ndocker-compose*.yml\nDockerfile*\nREADME.md\ntests\u002F\n```\n\n## Debugging\n\n### Common Commands\n\n```bash\n# View logs\ndocker compose logs -f app           # Follow app logs\ndocker compose logs --tail=50 db     # Last 50 lines from db\n\n# Execute commands in running container\ndocker compose exec app sh           # Shell into app\ndocker compose exec db psql -U postgres  # Connect to postgres\n\n# Inspect\ndocker compose ps                     # Running services\ndocker compose top                    # Processes in each container\ndocker stats                          # Resource usage\n\n# Rebuild\ndocker compose up --build             # Rebuild images\ndocker compose build --no-cache app   # Force full rebuild\n\n# Clean up\ndocker compose down                   # Stop and remove containers\ndocker compose down -v                # Also remove volumes (DESTRUCTIVE)\ndocker system prune                   # Remove unused images\u002Fcontainers\n```\n\n### Debugging Network Issues\n\n```bash\n# Check DNS resolution inside container\ndocker compose exec app nslookup db\n\n# Check connectivity\ndocker compose exec app wget -qO- http:\u002F\u002Fapi:3000\u002Fhealth\n\n# Inspect network\ndocker network ls\ndocker network inspect \u003Cproject>_default\n```\n\n## Anti-Patterns\n\n```\n# BAD: Using docker compose in production without orchestration\n# Use Kubernetes, ECS, or Docker Swarm for production multi-container workloads\n\n# BAD: Storing data in containers without volumes\n# Containers are ephemeral -- all data lost on restart without volumes\n\n# BAD: Running as root\n# Always create and use a non-root user\n\n# BAD: Using :latest tag\n# Pin to specific versions for reproducible builds\n\n# BAD: One giant container with all services\n# Separate concerns: one process per container\n\n# BAD: Putting secrets in docker-compose.yml\n# Use .env files (gitignored) or Docker secrets\n```\n",{"name":5,"description":7},"main","7542b2fc80051758dfb288b450cb344d3bdfca35","curation\u002Fskills\u002Fdocker-patterns",0,"https:\u002F\u002Fgithub.com\u002FMoradDev\u002Fskills-unified","https:\u002F\u002Fgithub.com\u002FMoradDev","2026-11-07 21:53:24",{"source":8,"skillName":5,"commands":31,"prompt":41,"zipAvailable":42},[32,35,38],{"tool":33,"command":34},"npx","npx skills add MoradDev\u002Fskills-unified --skill docker-patterns",{"tool":36,"command":37},"bunx","bunx skills add MoradDev\u002Fskills-unified --skill docker-patterns",{"tool":39,"command":40},"pnpm","pnpm dlx skills add MoradDev\u002Fskills-unified --skill docker-patterns","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FMoradDev\u002Fskills-unified\u002Fblob\u002Fmain\u002Fcuration\u002Fskills\u002Fdocker-patterns\u002FSKILL.md",true,[],[45,52,59,66,73,80],{"skillNo":46,"name":47,"nameZh":6,"description":48,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":49,"categories":50,"keywords":51,"publishedAt":18},"01M7DB9J6N2PSGECQ6FTWW7B2H","windows-desktop-e2e","E2E testing for Windows native desktop apps (WPF, WinForms, Win32\u002FMFC, Qt) using pywinauto and Windows UI Automation. Use when writing E2E tests for a Windows native desktop app with pywinauto or UI Automation.","https:\u002F\u002Fgithub.com\u002FMoradDev\u002Fskills-unified\u002Fblob\u002Fmain\u002Fcuration\u002Fskills\u002Fwindows-desktop-e2e\u002FSKILL.md",[],[],{"skillNo":53,"name":54,"nameZh":6,"description":55,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":56,"categories":57,"keywords":58,"publishedAt":18},"01M7DB9CCWT4YW7B791QN43E3Q","vue-patterns","Vue.js 3 Composition API patterns, component architecture, reactivity best practices, Pinia state management, Vue Router navigation, and Nuxt SSR patterns. Activates for Vue, Nuxt, Vite, or Pinia projects. Use when building or reviewing Vue 3, Nuxt, or Pinia code — Composition API, reactivity, or router navigation.","https:\u002F\u002Fgithub.com\u002FMoradDev\u002Fskills-unified\u002Fblob\u002Fmain\u002Fcuration\u002Fskills\u002Fvue-patterns\u002FSKILL.md",[],[],{"skillNo":60,"name":61,"nameZh":6,"description":62,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":63,"categories":64,"keywords":65,"publishedAt":18},"01M7DB976FM2CAWT807EA36MXM","vite-patterns","Vite build tool patterns including config, plugins, HMR, env variables, proxy setup, SSR, library mode, dependency pre-bundling, and build optimization. Activate when working with vite.config.ts, Vite plugins, or Vite-based projects.","https:\u002F\u002Fgithub.com\u002FMoradDev\u002Fskills-unified\u002Fblob\u002Fmain\u002Fcuration\u002Fskills\u002Fvite-patterns\u002FSKILL.md",[],[],{"skillNo":67,"name":68,"nameZh":6,"description":69,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":70,"categories":71,"keywords":72,"publishedAt":18},"01M7DB93JZRAWFB5QHH0C8DZ8N","using-agent-skills","Discovers and invokes agent skills. Use when starting a session, or when you need to decide which skill or workflow applies to the piece of work at hand. This is the meta-skill that governs how all other skills are discovered and invoked.","https:\u002F\u002Fgithub.com\u002FMoradDev\u002Fskills-unified\u002Fblob\u002Fmain\u002Fcuration\u002Fskills\u002Fusing-agent-skills\u002FSKILL.md",[],[],{"skillNo":74,"name":75,"nameZh":6,"description":76,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":77,"categories":78,"keywords":79,"publishedAt":18},"01M7DB8YYW1PEDS7H2AA86TE2E","ui-demo","Record polished UI demo videos using Playwright. Use when the user asks to create a demo, walkthrough, screen recording, or tutorial video of a web application. Produces WebM videos with visible cursor, natural pacing, and professional feel.","https:\u002F\u002Fgithub.com\u002FMoradDev\u002Fskills-unified\u002Fblob\u002Fmain\u002Fcuration\u002Fskills\u002Fui-demo\u002FSKILL.md",[],[],{"skillNo":81,"name":82,"nameZh":6,"description":83,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":84,"categories":85,"keywords":86,"publishedAt":18},"01M7DB8RPQPW2R6GKJW618VDST","swiftui-patterns","SwiftUI architecture patterns, state management with @Observable, view composition, navigation, performance optimization, and modern iOS\u002FmacOS UI best practices. Use when building or reviewing SwiftUI views, @Observable state, navigation, or render performance.","https:\u002F\u002Fgithub.com\u002FMoradDev\u002Fskills-unified\u002Fblob\u002Fmain\u002Fcuration\u002Fskills\u002Fswiftui-patterns\u002FSKILL.md",[],[]]