Skip to content
New

DeepSeek V4.1 Flash free for 7 days: 10M tokens a day after a top-up of $10 or more. Until Nov 30.

How it works
securityskills/container-image-hardeningLinux, cloud and containers

container-image-hardening

⁨Harden Dockerfiles and container images — multi-stage builds, non-root users, minimal base images, and vulnerability gates. Use when building production containers or reviewing Dockerfiles.⁩

v2026.8.26-b2b6b523 installs+3 in 7 days0 Starssynced 19 hours ago

Install

No NotHoly CLI yet? Install it first.

$ curl -fsSL https://notholy.com/install.sh | sh
$ notholy skills install securityskills/container-image-hardening

Writes to ⁦~/.notholy/skills⁩ after checking the signature and the SHA-256.

SignatureSigned, ed25519
0lbGfqXjie…1lkhNDCw==The CLI checks the SHA-256 and the signature before it writes a file.
Package3b9b73b2…dc5aa40a
3b9b73b2cb51…804bdc5aa40a1 file · ⁦1.1 KB⁩
ScanMedium1 finding
  • No license found
See the full scan
Sourcegithub.com/securityskills/skills/tree/main/container-security/docker/container-image-hardening@b2b6b52

Review and fix Dockerfiles and images for production safety.

Dockerfile Review Checklist

  • Base image: official, specific tag or digest, minimal variant (alpine, distroless, slim); never latest
  • Multi-stage builds: build toolchains (compilers, package managers) excluded from final image
  • Non-root user: USER directive with a dedicated UID; no sudo in image
  • No secrets: no ENV with credentials, no COPY .env, no secrets baked into layers (they persist even if deleted later)
  • Pinned dependencies: lockfiles used (npm ci, pip install -r requirements.txt with hashes)
  • Healthchecks defined; ENTRYPOINT over CMD for enforced init
  • Layer hygiene: combine apt operations and clean lists in one layer; .dockerignore covers .git, build artifacts

Scan and Gate

bash
trivy image --severity HIGH,CRITICAL --exit-code 1 <image>
grype <image>
docker scout cves <image>
  • Fail CI on critical CVEs with available fixes
  • Track base image updates (renovate/dependabot for Dockerfiles)

Runtime Hardening

yaml
read_only: true
cap_drop: ["ALL"]
security_opt: ["no-new-privileges:true"]
tmpfs: [/tmp]
  • Resource limits set (CPU/memory) to blunt DoS
  • Root filesystem read-only; writable paths explicit tmpfs

Verification

  • docker history <image> — no secret-looking layers
  • dive <image> — image efficiency and wasted space
  • Run as the image user: docker run --rm <image> id shows non-root

Output

Hardened Dockerfile, scan report before/after, and CI gate configuration.

Files in this version

Permissions

PermissionDeclaredFound by the scan
Reads filesNoNo
Writes filesNoNo
Runs shell commandsYesYes
Uses the networkNoNo
Uses connectorsNoNo
Drives a browserNoNo

Scan findings

Reviewed on Nov 13, 2026

  1. MediumLicense · No license found

A clean scan lowers the risk but does not prove a package is safe. Read what you install.

VersionPublishedCommitSHA-256SignaturePermission change
v2026.8.26-b2b6b52Nov 13, 2026b2b6b523b9b73b2Signed–

Ask anything your scope allows.

Create an account, add credits and ask the first question in the chat or the terminal.

  1. 1/3

    Create the account

    Individual or company. You can switch to a company later without losing balance or keys.

    IndividualCompany
  2. 2/3

    Add credits

    By card. Pay per token, no subscription.

    $5.00minimum deposit
  3. 3/3

    Ask

    In the chat, or install the CLI and run notholy login in your terminal.

    $ notholy login