docker

docker is a cursor rule for Cursor from nedcodes-ok/cursorrules-collection. It costs 823 tokens per session, scanned A, original, MIT.

A set of project rules for Docker, a tool that packages applications and their dependencies into portable containers.

In plain words
What is it for?
Use it when writing Dockerfiles and Compose setups, choosing base images, ordering build layers, creating multi-stage builds, installing from lockfiles, and running containers without root access.
Why use it?
It helps produce smaller, repeatable, cached, and safer container images while avoiding leaked secrets and unnecessary build files.

Cursor rule for Cursor

Written for Cursor: a Cursor rule (.mdc). Also seen: mentions Cursor.

Good fit Use it when writing Dockerfiles and Compose setups, choosing base images, ordering build layers, creating multi-stage builds, installing from lockfiles, and running containers without root access.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/nedcodes-ok/cursorrules-collection/docker
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.

Clone the repo
git clone --depth 1 https://github.com/nedcodes-ok/cursorrules-collection

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for docker

README.md
[![agentmods](https://agentmods.dev/badge/rules/nedcodes-ok/cursorrules-collection/docker/github.svg)](https://agentmods.dev/rules/nedcodes-ok/cursorrules-collection/docker)
Your own site
<a href="https://agentmods.dev/rules/nedcodes-ok/cursorrules-collection/docker"><img src="https://agentmods.dev/badge/rules/nedcodes-ok/cursorrules-collection/docker/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for docker

Your own site · 80×15
<a href="https://agentmods.dev/rules/nedcodes-ok/cursorrules-collection/docker"><img src="https://agentmods.dev/badge/rules/nedcodes-ok/cursorrules-collection/docker.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
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. A grade says what 26 rules found in the file — not that it is safe.
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.1 $0.00823 $0.00823
Opus 5 $0.00411 $0.00411
Sonnet 5 $0.00165 $0.00165
Haiku 4.5 $0.00082 $0.00082

Measured 5d ago against content hash aca5eaa31be8, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-09, 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 5d 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.

Origin

Copies of this mod

1 near-identical copy found in the catalogue:

  • docker — 100% identical, 0 lines differ
rules-mdc/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. 5d 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/cursorrules-collection (37 stars, last pushed 6mo 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-09-03.