Hub rules-docker

rules-docker

v6 public Verified

Docker

Docker is a platform for developing and running applications in containers. These rules guide AI agents in containerizing applications, managing Dockerfiles, and optimizing multi-stage builds and Docker Compose configurations.

@sigmashakeinc 9 pulls 15 rules published Apr 8, 2026 synced Oct 11, 2026 sigmashakeinc/rules/rulesets/rules-docker →
Severity
8 error 6 warn 1 info
demo.cast
Docker is a platform for developing and running applications in containers. These rules guide AI agents in containerizing applications, managing Dockerfiles, and optimizing multi-stage builds and Docker Compose configurations.

Rules index

15 governance rules

Indexed from the repository's .rules files, grouped by technology. Expand any rule to read the raw source.

docker

docker-apt-upgrade-in-layer warning log

RISK: 'apt-get upgrade' at build time pulls unpinned package versions, breaking reproducibility and potentially replacing a pinned base image's tested libraries. FIX: Rebuild on an updated base image tag/digest instead; install only the specific packages you need with 'apt-get install -y --no-install-recommends <pkg>=<version>'.

Rule source requires an active Pro or Enterprise subscription.
docker-cap-add-dangerous error block

RISK: CAP_SYS_ADMIN (and ALL/SYS_MODULE/SYS_PTRACE/DAC_READ_SEARCH) is effectively equivalent to root — it enables mount, kernel-module load, ptrace of host processes, and has been the pivot in multiple container-escape CVEs. FIX: Drop all capabilities and add back only the specific ones (e.g. NET_BIND_SERVICE) you need.

Rule source requires an active Pro or Enterprise subscription.
docker-chmod-world-writable warning log

RISK: chmod 777 inside the image makes files world-writable across every container user, defeating the non-root USER hardening and enabling tamper-on-write attacks. FIX: Set ownership with 'COPY --chown=app:app' and use 0755/0644.

Rule source requires an active Pro or Enterprise subscription.
docker-compose-latest-image warning log

RISK: ':latest' image tags in docker-compose are not pinned to an immutable digest; a silent tag re-push can introduce new CVEs or supply-chain compromises into your stack without any git diff. FIX: Pin to an explicit version tag or immutable digest, e.g. 'image: postgres:16.2@sha256:<digest>'.

Rule source requires an active Pro or Enterprise subscription.
docker-curl-pipe-shell error block

RISK: 'curl ... | sh' in a build layer executes arbitrary upstream content with no integrity check — a compromised CDN or typo-squatted domain becomes RCE in every rebuild. FIX: Download to a file, verify sha256, then execute; or install from a pinned package repository.

Rule source requires an active Pro or Enterprise subscription.
docker-expose-all-interfaces warning log

RISK: Binding 0.0.0.0 exposes the port on every host interface, including public ones, which has caused repeated unauthenticated DB exposures (Redis, Mongo, Elastic). FIX: Bind to 127.0.0.1 for dev; in prod rely on a reverse proxy or explicit firewall rules.

Rule source requires an active Pro or Enterprise subscription.
docker-expose-socket error block

RISK: Mounting /var/run/docker.sock grants the container control of the host Docker daemon (spawn privileged containers = host root). FIX: Use a scoped socket proxy (e.g. tecnativa/docker-socket-proxy) or the rootless API.

Rule source requires an active Pro or Enterprise subscription.
docker-host-namespace-share error block

RISK: Sharing the host network/PID/IPC namespace removes a core isolation boundary — the container can sniff host traffic, send signals to host processes, and access host SysV IPC. FIX: Use a user-defined bridge network and default namespaces; expose only the ports you need.

Rule source requires an active Pro or Enterprise subscription.
docker-latest-tag warning log

RISK: ':latest' (or untagged) base images break reproducibility and silently pull in new CVEs or malicious tag re-pushes. FIX: Pin to an immutable digest, e.g. 'FROM node:20.11.1-alpine@sha256:<digest>'.

Rule source requires an active Pro or Enterprise subscription.
docker-no-add-for-files warning log

RISK: ADD auto-extracts tar archives and fetches URLs with no checksum, introducing path-traversal and tampering surface. FIX: Use COPY for local files; for remote fetches use RUN curl with a verified sha256.

Rule source requires an active Pro or Enterprise subscription.
docker-no-new-privileges-missing info log

RISK: Without 'security_opt: [no-new-privileges:true]' a setuid binary inside the container can still gain privileges, undermining a non-root USER. FIX: Add 'security_opt:\n - no-new-privileges:true' to each service.

Rule source requires an active Pro or Enterprise subscription.
docker-privileged-mode error block

RISK: --privileged disables seccomp/AppArmor/capability dropping, giving the container full kernel access (equivalent to host root). FIX: Remove and grant only the specific capabilities needed via cap_add.

Rule source requires an active Pro or Enterprise subscription.
docker-run-as-root error block

RISK: Containers default to UID 0; combined with a runtime flaw (e.g. runc CVE-2025-31133/52565/52881) this yields host root. FIX: Add 'USER nonroot' (or a dedicated uid) before the final CMD/ENTRYPOINT.

Rule source requires an active Pro or Enterprise subscription.
docker-secrets-in-build-arg error block

RISK: ARG values are recorded in image history (docker history --no-trunc) and leak even when unset in the final image — documented by Docker build-checks SecretsUsedInArgOrEnv. FIX: Use 'RUN --mount=type=secret,id=foo' with BuildKit.

Rule source requires an active Pro or Enterprise subscription.
docker-secrets-in-env error block

RISK: Secrets in ENV or literal compose values are baked into the image layer and surfaced by 'docker inspect'/'docker history' forever. FIX: Use BuildKit '--mount=type=secret' at build time and Docker/K8s secrets or env-file injection at runtime.

Rule source requires an active Pro or Enterprise subscription.

Version metadata

Published metadata

The hash-locked record of this published ruleset. When source contents change, the maintainer resyncs and the version bumps.

Version
v6
Published
Apr 8, 2026
Source commits
0
Synced
Oct 11, 2026
Hash
7d3d5a3ac8482213407f9fe7750c60d47cd668312ca8224c08daf67e65155263
Signature
Verified (publisher key)
Tested with
claude-code@current
Plan
Starter (free)
Visibility
Public

Source history

Recent commits

Latest commits touching rulesets/rules-docker/.sigmashake/rules in sigmashakeinc/rules/rulesets/rules-docker. The published version only bumps when a maintainer resyncs.

No commit history available.