How to fix CVEs in nginx container images
Short answer
The nginx images' CVEs are mostly in the libraries of the base OS (image, XML and compression libraries pulled in by modules), not in nginx itself. Use the newest patch of the stable or mainline line, prefer the Alpine or slim variant, and upgrade OS packages in your own layer; nginx itself is fixed by moving to the release that fixes it.
Fix a nginx image now →
free, no sign-up; pre-filled with nginx:1.27, change it to yours
The steps
- 01Newest stable or mainline patchnginx fixes ship in new releases of both lines.
- 02Smaller variantnginx:alpine carries far fewer packages than the Debian image.
- 03Upgrade OS packagesFixes released since the image was built.
- 04Pin by digestTags such as 1.27 move: deploy the digest you tested.
By hand
FROM nginx:1.27 RUN apt-get update && apt-get upgrade -y && rm -rf /var/lib/apt/lists/* COPY nginx.conf /etc/nginx/nginx.conf
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
- Many reported CVEs are in libraries for modules you may not load; the report marks what is in use.
- An old patch tag stays on the old release: follow the line, pin the digest.
nginx images in OCImend's reports
| Image | Grade | Known CVEs | |
|---|---|---|---|
| nginx:1.28-alpine3.21-perl | F | 196 exploited | Fix |
| nginx:latest | A | 65 | Fix |
| docker.io/ubuntu/nginx:latest | A | 0 | Fix |
Questions
How do I fix CVEs in a nginx container image?
The nginx images' CVEs are mostly in the libraries of the base OS (image, XML and compression libraries pulled in by modules), not in nginx itself. Use the newest patch of the stable or mainline line, prefer the Alpine or slim variant, and upgrade OS packages in your own layer; nginx itself is fixed by moving to the release that fixes it.
Is nginx:alpine safe for production?
Yes, and it usually has far fewer CVEs than the Debian variant.
Should I use stable or mainline?
Either is supported; stable changes less, mainline gets features first.
Other image types
Python · Node.js · Java · Go · PostgreSQL · Alpine · Debian · Ubuntu · Red Hat UBI