Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
openaec-foundation avatar

Docker Core Security

  • 9 installs
  • 9 repo stars
  • Updated July 8, 2026
  • openaec-foundation/docker-claude-skill-package

Helps with security tasks.

About

docker-core-security is a Claude Code skill for security. It helps solo builders move faster with AI-assisted development.

  • docker-core-security
  • Security
  • AI-coding skill

Docker Core Security by the numbers

  • 9 all-time installs (skills.sh)
  • +1 installs in the week ending Aug 4, 2026 (Skillselion tracking)
  • Ranked #1,675 of 2,203 Security skills by installs in the Skillselion catalog
  • Data as of Aug 4, 2026 (Skillselion catalog sync)
npx skills add https://github.com/openaec-foundation/docker-claude-skill-package --skill docker-core-security

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs9
repo stars9
Last updatedJuly 8, 2026
Repositoryopenaec-foundation/docker-claude-skill-package

What it does

Helps with security tasks.

Files

SKILL.mdMarkdownGitHub ↗

docker-core-security

Quick Reference

Security Layers Overview

LayerMechanismPurpose
Image Supply ChainContent trust, scanning, pinned digestsVerify image integrity and known vulnerabilities
Build-TimeSecrets mounts, multi-stage builds, .dockerignorePrevent secrets leaking into image layers
Runtime IsolationNamespaces, cgroups, seccomp, AppArmorKernel-level process and resource isolation
Least PrivilegeNon-root USER, cap-drop ALL, read-only FSMinimize attack surface inside the container
Resource LimitsMemory, CPU, PID limitsPrevent denial-of-service via resource exhaustion
Host ProtectionRootless Docker, no-new-privilegesReduce daemon and container escape impact

Minimum Viable Security (Quick-Start)

Apply these five settings to EVERY production container:

# Dockerfile
FROM node:20-alpine
RUN addgroup -g 1001 -S appgroup && adduser -u 1001 -S appuser -G appgroup
WORKDIR /app
COPY --chown=1001:1001 . .
USER 1001:1001
CMD ["node", "server.js"]
# Runtime
docker run -d \
  --read-only \
  --tmpfs /tmp:size=64m \
  --cap-drop ALL \
  --security-opt no-new-privileges=true \
  -m 512m --cpus 1.5 --pids-limit 200 \
  myapp:v1
# Docker Compose equivalent
services:
  app:
    image: myapp:v1
    read_only: true
    tmpfs:
      - /tmp:size=64m
    cap_drop:
      - ALL
    security_opt:
      - no-new-privileges=true
    deploy:
      resources:
        limits:
          memory: 512m
          cpus: "1.5"
          pids: 200
    user: "1001:1001"

Critical Warnings

NEVER use --privileged in production -- it grants the container ALL host capabilities and access to ALL host devices. ALWAYS use specific --cap-add flags for the exact capabilities needed.

NEVER store secrets in Dockerfile ENV, ARG, or COPY instructions -- they persist in image layers and are visible via docker history. ALWAYS use --mount=type=secret for build-time secrets and Docker secrets or environment variables for runtime.

NEVER run containers as root unless there is a specific technical requirement -- most application workloads run correctly as non-root. ALWAYS add a USER instruction to your Dockerfile.

NEVER use latest tag in production -- it is mutable and prevents reproducible deployments. ALWAYS pin to a specific version tag or image digest.

NEVER expose the Docker daemon API over TCP without TLS -- API access equals root access on the host. ALWAYS use Unix socket (default) or SSH tunneling for remote access.

NEVER disable seccomp (--security-opt seccomp=unconfined) in production -- it removes syscall filtering that blocks container escapes. ALWAYS use the default seccomp profile or a custom restricted profile.

---

Security Hardening Decision Tree

Container needs hardening?
|
+-- Is the image from a trusted source?
|   +-- NO --> Pin to verified digest: FROM image@sha256:...
|   +-- YES --> Pin version tag, scan with Docker Scout
|
+-- Does the app need root?
|   +-- NO --> Add USER 1001:1001 to Dockerfile
|   +-- YES --> Document WHY, use --cap-drop ALL --cap-add <specific>
|
+-- Does the app write to the filesystem?
|   +-- NO --> Use --read-only
|   +-- YES to specific dirs --> Use --read-only --tmpfs /path
|   +-- YES broadly --> Skip --read-only, log a security debt ticket
|
+-- Does the app need special kernel access?
|   +-- NO --> Use --cap-drop ALL (add nothing)
|   +-- YES --> --cap-drop ALL --cap-add <EXACT_CAP> (see capabilities table)
|
+-- Is this exposed to the internet?
|   +-- YES --> Add resource limits, no-new-privileges, seccomp default
|   +-- NO --> Still apply resource limits (defense in depth)

---

Non-Root Containers

Dockerfile USER Instruction

ALWAYS use numeric UID/GID for deterministic behavior across environments:

# Alpine-based
RUN addgroup -g 1001 -S appgroup && adduser -u 1001 -S appuser -G appgroup
USER 1001:1001

# Debian/Ubuntu-based
RUN groupadd -r -g 1001 appgroup && useradd --no-log-init -r -u 1001 -g appgroup appuser
USER 1001:1001

Runtime Override

docker run -u 1001:1001 nginx
docker run --user nobody nginx

Compose

services:
  app:
    image: myapp:v1
    user: "1001:1001"

---

Linux Capabilities

Drop-All-Add-Specific Pattern

ALWAYS start with --cap-drop ALL and add back only what the application requires:

docker run --cap-drop ALL --cap-add NET_BIND_SERVICE nginx

Common Capabilities Reference

CapabilityPurposeWhen Needed
NET_BIND_SERVICEBind to ports < 1024Web servers on port 80/443
CHOWNChange file ownershipApps managing file permissions
SETUID / SETGIDChange process UID/GIDApps switching users at runtime
SYS_PTRACEProcess tracingDebugging, profiling tools
NET_ADMINNetwork configurationVPN containers, network tools
SYS_ADMINMount operations, broad accessAvoid -- use specific caps instead
DAC_OVERRIDEBypass file permission checksAvoid -- fix file permissions instead

Compose Syntax

services:
  app:
    cap_drop:
      - ALL
    cap_add:
      - NET_BIND_SERVICE

---

Read-Only Root Filesystem

ALWAYS use --read-only with --tmpfs for directories that require writes:

docker run --read-only \
  --tmpfs /tmp:size=64m \
  --tmpfs /run:size=16m \
  --tmpfs /var/cache/nginx:size=32m \
  nginx

Compose

services:
  app:
    read_only: true
    tmpfs:
      - /tmp:size=64m
      - /run:size=16m

---

Seccomp and AppArmor Profiles

Seccomp (Syscall Filtering)

Docker applies a default seccomp profile that blocks ~44 dangerous syscalls. ALWAYS keep this enabled.

# Default profile (applied automatically)
docker run --security-opt seccomp=default nginx

# Custom restrictive profile
docker run --security-opt seccomp=custom-profile.json nginx

AppArmor (Mandatory Access Control)

# Default Docker AppArmor profile
docker run --security-opt apparmor=docker-default nginx

# Custom profile
docker run --security-opt apparmor=my-custom-profile nginx

No-New-Privileges

ALWAYS enable this to prevent processes inside the container from gaining additional privileges via setuid/setgid binaries:

docker run --security-opt no-new-privileges=true nginx

---

Content Trust and Image Signing

DOCKER_CONTENT_TRUST

# Enable globally
export DOCKER_CONTENT_TRUST=1

# With content trust enabled:
docker pull nginx          # Fails if image is not signed
docker push myapp:v1       # Automatically signs the image

Digest Pinning

ALWAYS pin production base images to a digest for supply chain security:

FROM alpine@sha256:c5b1261d6d3e43071626931fc004f70149baed4c52b3b3d4f8d72af0a7e2d708

---

Image Scanning

Docker Scout

# Quick vulnerability overview
docker scout quickview myapp:v1

# Detailed CVE listing
docker scout cves myapp:v1

# Critical and high severity only
docker scout cves --only-severity critical,high myapp:v1

# Only fixable vulnerabilities
docker scout cves --only-fixed myapp:v1

# Compare versions for upgrade decisions
docker scout compare myapp:v1 --to myapp:v2

# Get base image upgrade recommendations
docker scout recommendations myapp:v1

# CI/CD gate (exit code 2 if vulnerabilities found)
docker scout cves -e myapp:v1

Trivy

# Scan local image
trivy image myapp:v1

# Critical/high only
trivy image --severity CRITICAL,HIGH myapp:v1

# Exit code for CI (1 if vulns found)
trivy image --exit-code 1 --severity CRITICAL myapp:v1

# Scan filesystem
trivy fs .

# Generate SBOM
trivy image --format spdx-json -o sbom.json myapp:v1

Snyk

# Scan image
snyk container test myapp:v1

# With Dockerfile for remediation advice
snyk container test myapp:v1 --file=Dockerfile

# Monitor for new vulnerabilities
snyk container monitor myapp:v1

See references/scanning.md for complete scanning integration details.

---

Resource Limits (DoS Prevention)

ALWAYS set resource limits on production containers:

docker run -d \
  -m 512m --memory-swap 1g \
  --cpus 1.5 \
  --pids-limit 200 \
  --ulimit nofile=1024:2048 \
  myapp:v1
FlagPurposeRecommended
-m, --memoryHard memory limitSet based on application profiling
--memory-swapMemory + swap limitSet to 2x memory or equal to prevent swap
--cpusCPU quotaMatch to workload, start conservative
--pids-limitMax processes (fork bomb prevention)200 for most apps, 100 for simple services
--ulimit nofileFile descriptor limit1024:2048 for most apps

---

Rootless Docker

Runs BOTH the daemon and containers entirely without root privileges.

# Install (as non-root user)
dockerd-rootless-setuptool.sh install

# Configure environment
export DOCKER_HOST=unix:///run/user/$(id -u)/docker.sock

# Enable auto-start with lingering
sudo loginctl enable-linger $(whoami)

# Manage via systemd user units
systemctl --user start docker
systemctl --user enable docker

Key limitation: Rootless mode does NOT support AppArmor, overlay network drivers on older kernels, or --net=host on all configurations. ALWAYS test your workload in rootless mode before committing to it.

---

Build-Time Secret Management

NEVER bake secrets into image layers. ALWAYS use BuildKit secret mounts:

# syntax=docker/dockerfile:1
RUN --mount=type=secret,id=aws_creds,target=/root/.aws/credentials \
    aws s3 cp s3://bucket/file /app/file
docker buildx build --secret id=aws_creds,src=$HOME/.aws/credentials .

SSH Agent Forwarding

docker buildx build --ssh default=$SSH_AUTH_SOCK .
RUN --mount=type=ssh git clone git@github.com:org/private-repo.git

---

Docker Bench for Security

Automated audit against CIS Docker Benchmark:

docker run --rm --net host --pid host \
  --userns host --cap-add audit_control \
  -e DOCKER_CONTENT_TRUST=$DOCKER_CONTENT_TRUST \
  -v /var/lib:/var/lib:ro \
  -v /var/run/docker.sock:/var/run/docker.sock:ro \
  -v /usr/lib/systemd:/usr/lib/systemd:ro \
  -v /etc:/etc:ro \
  docker/docker-bench-security

ALWAYS run Docker Bench before deploying to production. Address all WARN findings in sections 1-5.

---

Supply Chain Security

SBOM (Software Bill of Materials)

# Generate SBOM during build
docker buildx build --sbom=true --push -t myapp:v1 .

# Scan existing image SBOM
docker scout sbom myapp:v1

Provenance Attestations

# Enable SLSA provenance
docker buildx build --provenance=mode=max --push -t myapp:v1 .

---

Reference Links

  • references/scanning.md -- Docker Scout, Trivy, Snyk integration and CI/CD pipeline patterns
  • references/hardening-checklist.md -- Complete security hardening checklist for audits
  • references/anti-patterns.md -- Security anti-patterns with exploit scenarios

Official Sources

  • https://docs.docker.com/engine/security/
  • https://docs.docker.com/engine/security/rootless/
  • https://docs.docker.com/scout/
  • https://docs.docker.com/reference/cli/docker/scout/cves/
  • https://docs.docker.com/build/building/best-practices/
  • https://docs.docker.com/engine/security/seccomp/
  • https://docs.docker.com/engine/security/apparmor/

Related skills

Securityappsec

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.