Generate production-ready Docker Cursor rules for Project Rules (.mdc), AGENTS.md, or legacy .cursorrules. This template encodes stack-specific conventions for projects using Docker. Container platform for packaging apps and dependencies into portable runtimes.
The template focuses Cursor AI on concrete Docker practices instead of generic coding advice. Required sections are always included; optional sections can be enabled when they match your project.
Required guidance
- Dockerfile Best Practices
- Docker Compose
- Security
- Image Optimization
Default style
- Indentation: 2 spaces
- Quotes: double
- Semicolons: disabled
- Naming: camelCase
Example Docker Rules
The generator turns these sections into Project Rules with frontmatter, AGENTS.md, or a single .cursorrules file depending on the output format you choose.
Dockerfile Best Practices
- Use multi-stage builds to minimize image size.
- Use specific base image tags — avoid :latest.
- Use 2 spaces for indentation.
- Combine RUN commands with && to reduce layers.
- Use .dockerignore to exclude unnecessary files.
- Use COPY over ADD unless you need URL or archive extraction.
Docker Compose
- Define services in docker-compose.yml with explicit dependencies.
- Use depends_on with healthcheck conditions for startup ordering.
- Use named volumes for persistent data.
- Use environment variables and .env files — never hardcode secrets.
- Use profiles for optional services.
- Pin service image versions — don't use :latest in compose files.
Security
- Never run containers as root — use USER directive.
- Use non-root base images when available (node:slim, python:slim).
- Scan images with docker scout or trivy before deployment.
- Use secrets management (Docker secrets, HashiCorp Vault) — not env vars.
- Use read-only root filesystem when possible (--read-only).
- Limit container capabilities with --cap-drop and --cap-add.
What does the Docker Cursor rules template include?
It includes 4 rule sections covering dockerfile best practices, docker compose, security and other Docker development conventions.
Can I generate Docker Project Rules and AGENTS.md from the same template?
Yes. The generator can export the same stack-specific guidance as modern Project Rules (.mdc), AGENTS.md, or a legacy .cursorrules file.
Should I combine Docker with other Cursor rules templates?
Yes. You can combine Docker with related templates such as TypeScript, Tailwind CSS, Docker, or backend frameworks when your project uses multiple technologies.