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-hardeningWrites to ~/.notholy/skills after checking the signature and the SHA-256.
SignatureSigned, ed25519
Package3b9b73b2…dc5aa40a
3b9b73b2cb51…804bdc5aa40a1 file · 1.1 KBScanMedium1 finding
- No license found
Sourcegithub.com/securityskills/skills/tree/main/container-security/docker/container-image-hardening@b2b6b52
On this page
Review and fix Dockerfiles and images for production safety.
Dockerfile Review Checklist
- Base image: official, specific tag or digest, minimal variant (
alpine,distroless,slim); neverlatest - Multi-stage builds: build toolchains (compilers, package managers) excluded from final image
- Non-root user:
USERdirective with a dedicated UID; no sudo in image - No secrets: no
ENVwith credentials, noCOPY .env, no secrets baked into layers (they persist even if deleted later) - Pinned dependencies: lockfiles used (
npm ci,pip install -r requirements.txtwith hashes) - Healthchecks defined;
ENTRYPOINToverCMDfor enforced init - Layer hygiene: combine apt operations and clean lists in one layer;
.dockerignorecovers.git, build artifacts
Scan and Gate
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
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 layersdive <image>— image efficiency and wasted space- Run as the image user:
docker run --rm <image> idshows non-root
Output
Hardened Dockerfile, scan report before/after, and CI gate configuration.
Files in this version
- SKILL.md1.8 KB
Permissions
| Permission | Declared | Found by the scan |
|---|---|---|
| Reads files | No | No |
| Writes files | No | No |
| Runs shell commands | Yes | Yes |
| Uses the network | No | No |
| Uses connectors | No | No |
| Drives a browser | No | No |
Scan findings
Reviewed on Nov 13, 2026
- MediumLicense · No license found
A clean scan lowers the risk but does not prove a package is safe. Read what you install.
| Version | Published | Commit | SHA-256 | Signature | Permission change |
|---|---|---|---|---|---|
| v2026.8.26-b2b6b52 | Nov 13, 2026 | b2b6b52 | 3b9b73b2 | Signed | – |
More from securityskills
All from this publisherMore in Linux, cloud and containers
See the category- detecting-aws-credential-exposure-with-trufflehogmukul975/detecting-aws-credential-exposure-with-trufflehog5
- cloud-gcpnoorqureshi/cloud-gcp4
- performing-cloud-incident-containment-proceduresmukul975/performing-cloud-incident-containment-procedures3
- implementing-taxii-server-with-opentaxiimukul975/implementing-taxii-server-with-opentaxii3
- detecting-cryptomining-in-cloudmukul975/detecting-cryptomining-in-cloud3
- detecting-azure-service-principal-abusemukul975/detecting-azure-service-principal-abuse3
Ask anything your scope allows.
Create an account, add credits and ask the first question in the chat or the terminal.
- 1/3
Create the account
Individual or company. You can switch to a company later without losing balance or keys.
IndividualCompany - 2/3
Add credits
By card. Pay per token, no subscription.
$5.00minimum deposit - 3/3
Ask
In the chat, or install the CLI and run notholy login in your terminal.
$ notholy login