Docker

From kid-sid/codex-spellbook · View interactive version

Docker is an AI agent skill from the GitHub repository kid-sid/codex-spellbook. Containerization guidance for multi-stage builds, non-root execution, dockerignore hygiene, layer caching, healthchecks, and secret handling. Use when writing or reviewing Dockerfiles and container images.

How to use this skill

Skill file

Docker

Build minimal, reproducible images that start fast, run as non-root, and separate build-time concerns from runtime behavior.

When to Activate

Base Images and Layering

| Use Case | Preferred | Avoid |

| --- | --- | --- |

| Production service | Distroless or slim runtime | Full distro with build toolchain |

| Build stage | Language-specific SDK image | Installing compilers in runtime image |

| Tiny static binary | scratch when feasible | Heavy general-purpose images |

| Order | Reason |

| --- | --- |

| Copy lockfiles first | Maximizes dependency cache hits |

| Install dependencies | Expensive step stays cached |

| Copy source later | Code changes do not bust dependency layer |

Runtime Hardening

BAD

FROM python:3.12-slim
WORKDIR /app
COPY . .
CMD ["python", "main.py"]

GOOD

FROM python:3.12-slim AS runtime
WORKDIR /app
RUN useradd --create-home appuser
COPY --chown=appuser:appuser . .
USER appuser
CMD ["python", "main.py"]

| Scenario | Rule |

| --- | --- |

| Build-time private dependency access | Use ephemeral build secrets if available |

| Runtime credentials | Inject via environment or secret store |

| Static secret in Dockerfile | Never do it |

| Preferred | Avoid |

| --- | --- |

| Application-level readiness endpoint | Checking only whether PID exists |

| Fast, dependency-light command | Heavy scripts that change container state |

Ignore List

| Always Ignore |

| --- |

| .git |

| node_modules |

| .venv |

| test artifacts |

| local secrets and .env files |

BAD

COPY . .
RUN npm install

GOOD

COPY package.json pnpm-lock.yaml ./
RUN pnpm install --frozen-lockfile
COPY . .

Checklist

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.