Pcornel
Browse topics
Options
Recent
Favorites
Security · Technical reference

Secrets · Container Security

Direct answer

Container secrets should be injected at runtime from a secret store or orchestrator secrets, mounted as files with tight permissions, never baked into images or committed in Dockerfiles.

When to use this

Use this when giving containers passwords, tokens and keys safely.

First 30 seconds

1. Container secrets: from secret managers via CSI/External Secrets.

2. Kubernetes Secrets need encryption at rest (KMS) and RBAC.

3. Avoid env vars in logs.

4. Never bake into images.

5. Rotate.

Operational verification

secret store → CSI/external secrets → pod

Context & applicabilityCommon mistakes · platform/version boundaries
Platform / version applicability
Platform and workload security
applies
Structured applicability is explicit Topic metadata; it does not infer compatibility beyond the stored rows.
At a glance

Operational reference

Fast context before you go deeper.

PlatformPlatform and workload security
Scope / prerequisiteUse this when giving containers passwords, tokens and keys safely.
What next?3 suggested next steps
Evidence1
On this pageJump to a specific section
Operational workflow

Verification & Troubleshooting

Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.

1 steps Observe → verify → isolate → change minimally → repeat the original test.
ObservedRecord what the original test actually shows

Capture the concrete output, symptom, packet, log or counter before changing anything.

Step 1 Common mistakes Narrow the fault
  • Secrets in Dockerfile ENV or build args.
  • Kubernetes Secrets in Git without SOPS/Sealed Secrets.
Evidence references

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.

observation · 1
Key points
  • Inject at runtime, not at build time.
  • Mount as files with tight permissions.
  • Use external secret stores for GitOps.
Key checks
  • kubectl get secrets -A — (check RBAC to secrets)
  • kubectl get pods -A -o yaml | grep -i -A2 'env:' — secrets in env (review)
  • External Secrets/CSI driver usage — vault integration
ReferenceWhy it matters1 section · depth on demand

Options

MethodNote
Environment variablesSimple; visible in docker inspect and process environment
Mounted files (tmpfs)Preferred; Docker/Kubernetes secrets
External manager (Vault, cloud)Rotation, audit
Kubernetes SecretBase64, not encrypted unless etcd encryption is on
ReferenceImportant terms & boundaries1 section · depth on demand

In depth

Secrets in containers must never be baked into images — anyone who can pull the image (or inspect its layers) can read them, and they remain in layer history even if deleted later.

Better options:

MethodNotes
Kubernetes Secrets mounted as filesEnable encryption at rest; restrict RBAC
External secret stores via operators/CSIVault, cloud secret managers
Workload identityCloud access without stored credentials
Build secrets (BuildKit --secret)Secrets during build without persisting in layers
docker build --secret id=npmrc,src=$HOME/.npmrc .
trivy image --scanners secret registry.example.com/app:1.4.0
Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.
ReferenceConfiguration & state1 section · depth on demand

Lifecycle

Use least privilege, bounded rollout and explicit exception handling.

Preserve a known-good pre-state, validate dependencies and trust anchors before disruptive changes, and avoid weakening a control merely to make a test pass.

Secrets, private keys, tokens and sensitive indicators remain redacted while stable references survive.

Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Technical verification history

Verification history & basis

When and against what this Topic was checked. Later text edits do not count as a new check.

2026-09-14 · vendor docPlatform and workload security current

Authoritative/upstream documentation reviewed for bounded claims in Container Security → Secrets. Documentation verification only; this is not observed lab or production Evidence.

Basis: https://csrc.nist.gov/pubs/sp/800/190/final · confidence 94%
Confirmation

Confirm action

Continue?