container-image-hardening
Installation
SKILL.md
Container Image Hardening
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