CursorDockerSecurity

Docker Cursor Rules

Cursor rules for Docker: multi-stage builds, security hardening, layer optimization, and production-ready Dockerfile conventions.

.cursorrules
- Use official minimal base images (alpine, distroless, slim variants)
- Always use multi-stage builds to keep production images small and secure
- Never run containers as root; add USER directive with a non-root user
- Pin base image versions with digest (FROM node:20-alpine@sha256:...)
- Combine RUN commands to minimize layers; clean package manager cache
- Use .dockerignore to exclude node_modules, .git, secrets, and build artifacts
- Never bake secrets into images; use build args only for non-sensitive build config
- Set HEALTHCHECK instructions for production services

How to use with Cursor

Create a `.cursorrules` file in your project root and paste these rules. Cursor reads this automatically on every AI interaction.

#docker#containers#security#cursor#coding-rules

Related Rules