docker

A set of rules for writing Dockerfiles and Docker Compose configurations. Docker packages an application and its dependencies into containers, while Compose defines and runs groups of containers.

In plain words
What is it for?
Use it when building or reviewing containerized applications. It guides multi-stage builds, dependency selection, image contents, non-root users, and Compose-based services.
Why use it?
It helps produce smaller, safer, repeatable application images and more reliable deployments. The guidance separates build tools from runtime files and avoids running applications as root.

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/sanjeed5/awesome-cursor-rules-mdc/docker
Clone the repo
git clone --depth 1 https://github.com/sanjeed5/awesome-cursor-rules-mdc
Per session 1,836 This file is loaded in full into every session.
When invoked 1,836 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.01836 $0.01836
Opus 5 $0.00918 $0.00918
Sonnet 5 $0.00367 $0.00367
Haiku 4.5 $0.00184 $0.00184

Measured 3d ago against content hash 71692f33f0d5, 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 3d 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.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

CMD curl -f http://localhost:3000/health || exit 1
Origin

Copies of this mod

1 near-identical copy found in the catalogue:

rules-mdc/docker.mdc · 247 lines

How it starts

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

docker Best Practices

Docker is the cornerstone of modern container-first development. Treat your Dockerfile and docker-compose.yml as critical source code. These rules ensure your images are fast, secure, reproducible, and aligned with modern DevOps practices.

1. Optimize for Multi-Stage Builds

Always use multi-stage builds. This pattern isolates build-time dependencies from runtime, drastically reducing final image size and attack surface.

❌ BAD: Single-stage build with all dependencies

FROM node:20
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build
CMD ["node", "dist/server.js"]

✅ GOOD: Multi-stage build for production

# Stage 1: Build application artifacts
FROM node:20-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production # Install only production dependencies for build
COPY . .
RUN npm run build

# Stage 2: Create minimal runtime image
FROM node:20-alpine
WORKDIR /app
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/node_modules ./node_modules # Copy only necessary runtime modules
USER node # Run as non-root user
EXPOSE 3000
CMD ["node", "dist/server.js"]

2. Choose Minimal, Trusted Base Images

Start with the smallest possible base image from a trusted source (Docker Official Images, Verified Publishers). Alpine variants are often the best choice for minimal footprints.

❌ BAD: Large, generic base image

FROM ubuntu:latest # Too large, many unnecessary packages and vulnerabilities

✅ GOOD: Minimal, specific base image

FROM node:20-alpine # Official, small, specific to Node.js
# Or for static content:
FROM nginx:alpine

3. Leverage .dockerignore

Always use a .dockerignore file to exclude irrelevant files and directories from your build context. This significantly speeds up builds and prevents sensitive or unnecessary files from being copied into the image.

❌ BAD: No .dockerignore (sends node_modules, .git, .env, etc., to the daemon)

Read the full file on GitHub · 247 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. 3d ago First seen · 247 lines · 0 tokens per session scan A 71692f33f0d5

Subscribe to this mod's changes

docker is a cursor rule published in the GitHub repository sanjeed5/awesome-cursor-rules-mdc (3,570 stars, last pushed 3mo ago), licensed CC0-1.0. It adds 1,836 tokens to every session, about $0.0092 per session on Opus 5. A static security scan graded it A with 1 finding (makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.