OCImendby CloudTrace

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

  1. 01Newest stable or mainline patchnginx fixes ship in new releases of both lines.
  2. 02Smaller variantnginx:alpine carries far fewer packages than the Debian image.
  3. 03Upgrade OS packagesFixes released since the image was built.
  4. 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

nginx images in OCImend's reports

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

Fix a nginx image now →