brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: trivy config checks a Dockerfile for security mistakes before you build it

Security
~/tips/tip-security-trivy-config-dockerfile

trivy config .

Scans Dockerfiles and other config files for risky settings like running as root.

trivy image looks for known flaws in packages. trivy config looks at how you wrote your files, and it catches the things you did yourself.

Point it at a folder with a Dockerfile, Kubernetes manifests, Helm charts or Terraform:

trivy config .
trivy config --severity HIGH,CRITICAL ./build

For a two line Dockerfile with FROM alpine and RUN apk add curl, it reported two HIGH findings: no USER line, so the container runs as root, and apk add without --no-cache. Every finding has an ID, a short reason, the line number and a link with more detail.

The root finding is the one I care about most. Adding a USER line with a normal account is cheap, and it takes away a lot of what an attacker can do inside the container.

It also runs fine from the official image, without installing anything:

docker run --rm -v "$PWD":/src:ro aquasec/trivy config /src

Don’t treat a clean result as approval. The checks cover common mistakes, not your app logic, and some findings are just advice about image size. The docs say Trivy downloads its checks bundle from the internet. In a test without network, version 0.75 still ran with the checks built into the binary, but those can be older than the online bundle.

Further reading: Trivy docs: misconfiguration scanning

More Security tips tcpdump -nn -r capture.pcap port 53 mkcert -install Strict-Transport-Security: max-age=0 Referrer-Policy: strict-origin-when-cross-origin wp super-admin list All Security tips (79) All topics

Link