docker

A set of Docker rules for building and running applications in containers, including image structure, dependency caching, security, and Docker Compose.

In plain words
What is it for?
Use it when writing Dockerfiles, choosing base images, installing dependencies, setting container users, handling secrets, or configuring multi-container applications.
Why use it?
It helps avoid slow or unpredictable builds, oversized images, leaked secrets, and containers running with unnecessary privileges.

Cursor rule

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/nedcodes-ok/cursor-doctor/docker
Clone the repo
git clone --depth 1 https://github.com/nedcodes-ok/cursor-doctor
Per session 823 This file is loaded in full into every session.
When invoked 823 The same file — it is already loaded in full.
Security scan A 1 finding. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00823 $0.00823
Opus 5 $0.00411 $0.00411
Sonnet 5 $0.00165 $0.00165
Haiku 4.5 $0.00082 $0.00082

Measured 2d ago against content hash aca5eaa31be8, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

docker scanned grade A with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Asks for rootlowPrivilege escalation

A mod that escalates privileges can change anything on the machine, not only the project.

- Never run as root: `RUN addgroup -S app && adduser -S app -G app` then `USER app` before CMD. Root in a container = root on the host if there's an escape

Downgraded: this mod is about security review, or the phrase is quoted, so it is likely naming the pattern rather than instructing it.

pro-kit/templates/tools/docker.mdc · 42 lines

How it starts

The opening of the file, as written. The whole thing — 42 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Docker Cursor Rules

You are an expert Docker developer. Follow these rules:

Dockerfiles

  • Use specific base image tags (node:20-alpine, not node:latest) — latest changes without warning and breaks builds
  • Order layers from least to most frequently changing: OS deps → language deps → build tools → application code. Each change invalidates all layers after it
  • Multi-stage builds to reduce final image size: build stage with dev dependencies, production stage copies only the compiled output. A Node.js app can go from 1GB to 150MB
  • Copy dependency files first, install, then copy source: COPY package*.json ./RUN npm ciCOPY . . — this caches the expensive install step when only source code changes
  • .dockerignore is not optional: exclude node_modules, .git, *.md, .env, test files — without it, your build context is huge and cache invalidation is unpredictable
  • RUN npm ci not RUN npm install — ci uses the lockfile exactly, install might update it

Security

  • Never run as root: RUN addgroup -S app && adduser -S app -G app then USER app before CMD. Root in a container = root on the host if there's an escape
  • Secrets never in the image: no ENV SECRET=..., no COPY .env . — use runtime env vars, Docker secrets, or mounted config files
  • Scan images with Trivy or Snyk in CI — vulnerabilities in base images are your vulnerabilities
  • Minimal base images: alpine (5MB), distroless (no shell at all), or slim variants. Full Debian/Ubuntu images carry hundreds of unnecessary packages
  • HEALTHCHECK instruction so Docker knows when your container is actually ready, not just running. Without it, a crashed app inside a "running" container gets no restart

Compose

  • Named volumes for persistent data (db-data:) — anonymous volumes get garbage collected and your data disappears
  • Resource limits on every service: deploy.resources.limits.memory: 512M — one runaway container shouldn't OOM the entire host
  • depends_on with condition: service_healthy (not just service_started) to wait for actual readiness — database containers start fast but take seconds to accept connections
  • .env files for configuration, but never commit them — use .env.example with placeholder values
  • restart: unless-stopped for production services — always restarts even when you manually stop, which is annoying during debugging

Read the full file on GitHub · 42 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 42 lines · 823 tokens per session scan A aca5eaa31be8

Subscribe to this mod's changes

docker is a cursor rule published in the GitHub repository nedcodes-ok/cursor-doctor (9 stars, last pushed 5mo ago), licensed MIT. It adds 823 tokens to every session, about $0.0041 per session on Opus 5. A static security scan graded it A with 1 finding (asks for root). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.