Use this when building trustworthy container images.
Image Security
Image security means building containers from minimal, trusted, pinned base images, keeping them patched, avoiding secrets in layers and signing images so only verified ones are deployed.
1. Image security: minimal trusted bases, pinned digests, no secrets in layers, non-root user.
2. Rebuild often for patches.
3. Sign images.
4. Generate SBOMs.
5. Multi-stage builds.
Dockerfile → build → scan → sign → registry
Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 Common mistakes Narrow the fault
- Secrets baked into image layers (
docker historyshows them).
Evidence · 1 on this Topic
Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.
- Pin base images by digest.
- Use multi-stage builds to keep images small.
- Sign images.
- Base image policy (minimal/distroless) — attack surface
cosign verify <image>— signaturesyft <image> -o table— SBOM contents
ReferenceWhy it matters1 section · depth on demand
Practices
- Minimal base images (distroless, Alpine,
-slim). - Pin by digest:
image@sha256:…. - Multi-stage builds; no compilers in the runtime image.
- Run as non-root (
USER 10001). - Sign images (cosign) and verify at admission.
ReferenceImportant terms & boundaries2 sections · depth on demand
How it works
Image security starts at build time: minimal base images, pinned versions, no secrets in layers, non-root users, then scanning, signing and admission policies that only allow trusted images to run.
Example
FROM python:3.12-slim AS run
RUN useradd -u 10001 app
USER 10001
COPY --chown=10001 app/ /app/
ENTRYPOINT ["python", "/app/main.py"]
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in Container Security → Image Security. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://csrc.nist.gov/pubs/sp/800/190/final · confidence 94%