How to fix CVEs in Alpine container images
Short answer
Alpine images are small, so their CVEs are few and almost always fixed by apk upgrade on a supported release branch. Upgrade packages in your image, move to a supported Alpine release when yours reaches its end of support, and keep the image small so there is little to patch.
Fix a Alpine image now →
free, no sign-up; pre-filled with alpine:3.20, change it to yours
The steps
- 01apk upgradeApplies the fixes published for your release branch.
- 02Stay on a supported branchOld branches stop receiving fixes: move to a newer release.
- 03Install with --no-cacheNo package index left behind in the image.
- 04Pin by digestDeploy exactly what you scanned.
By hand
FROM alpine:3.20 RUN apk upgrade --no-cache RUN apk add --no-cache ca-certificates
Then rescan: the CVEs that remain are either without a released fix or in code the application never loads (the report marks both).
Traps that bring CVEs back
- An end-of-support branch keeps its CVEs: no new fixes are published for it.
- busybox and musl are in every Alpine image; their fixes arrive through apk upgrade.
Alpine images in OCImend's reports
| Image | Grade | Known CVEs | |
|---|---|---|---|
| alpine:3.20 | B | 0 | Fix |
| alpine:3.20 | B | 0 | Fix |
Questions
How do I fix CVEs in a Alpine container image?
Alpine images are small, so their CVEs are few and almost always fixed by apk upgrade on a supported release branch. Upgrade packages in your image, move to a supported Alpine release when yours reaches its end of support, and keep the image small so there is little to patch.
How long is an Alpine release supported?
Alpine supports each stable branch for about two years; check the release page for your branch.
Does apk upgrade change behaviour?
Within a branch it applies fixes, not new major versions.
Other image types
Python · Node.js · Java · Go · nginx · PostgreSQL · Debian · Ubuntu · Red Hat UBI