Rule

0 installs · 0 said it worked

PatrickJS@patrickjs·
CodingRule· for Cursor

Production Docker rules for secure, reproducible container images

Cursor rules that make the assistant an expert Docker practitioner, guiding pinned versions, multi-stage builds, non-root users, safe secrets handling, and proper .dockerignore, volume, networking, and logging practices.

People use this for

  • docker production dockerfile rules
  • pinned docker image versions
  • secure docker container best practices
  • how to write multi-stage dockerfile
  • non-root docker container setup
Name
production-docker-rules-for-secure-reproducible-container-images
Works with
Cursor
License
CC0(as observed at the source)
Version
v1 · updated Nov 29, 2026
Imported · UnclaimedCC0

Imported on Nov 29, 2026 from github.com . License observed at the source on Nov 29, 2026: CC0.

Are you the author?Claim this profileRequest removal

Use this rule

$ curl -fsSL "https://promptcommunity.dev/api/v1/posts/production-docker-rules-for-secure-reproducible-container-images-ruuj/export/mdc" -o .cursor/rules/production-docker-rules-for-secure-reproducible-container-images.mdc

Then open a new session; Cursor picks it up from .cursor/rules/.

Download production-docker-rules-for-secure-reproducible-container-images.mdc
Manual install

Save production-docker-rules-for-secure-reproducible-container-images.mdc as .cursor/rules/production-docker-rules-for-secure-reproducible-container-images.mdc for this project or ~/.cursor/rules/production-docker-rules-for-secure-reproducible-container-images.mdc for every project, then start a new session.

Rule


description: "Docker production rules. Pinned versions, multi-stage builds, non-root user, minimal attack surface." globs: Dockerfile, Dockerfile., docker-compose.yml, docker-compose*.yaml, .dockerignore alwaysApply: false

Docker Rules

Expert Docker practitioner. Minimal, secure, reproducible images.

Dockerfile

  • Pin versions: FROM node:20.11-alpine3.19 (never :latest)
  • Multi-stage builds for compiled languages
  • Layer cache: copy package files → install → copy source
  • Combine RUN commands with && to minimize layers
  • USER non-root before CMD
  • HEALTHCHECK on all services
  • COPY --chown=appuser:appuser for file ownership

Security

  • Never run as root
  • No secrets in Dockerfile or image layers
  • No .env files copied into image
  • Scan with docker scout or trivy in CI

.dockerignore

  • Always present: node_modules, .git, .log, .env, test files

Volumes

  • Named volumes for persistence
  • Bind mounts for dev only, never production

Networking

  • Custom bridge networks, not host networking
  • Reference services by name in compose

Logging

  • Always stdout/stderr — never log to files inside container

Forbidden

  • No :latest tags in production
  • No ADD when COPY works
  • No root user in production
  • No secrets in build args or image layers

No result recorded yet. Added it? File a Tried-it report so the next person knows how it went in your editor.

Tried it

Reports from people who added this rule to their editor. They roll up into the badges above.

No one has filed a report yet. Try the prompt and be the first.

License: CC0v1 · published Nov 29, 2026

Comments

No comments yet. If you tried this prompt, say how it went.