Skip to content

Install packages without docs to reduce image size - #897

Open
abrarshivani wants to merge 1 commit into
NVIDIA:mainfrom
abrarshivani:fix/install-packages-nodocs
Open

Install packages without docs to reduce image size#897
abrarshivani wants to merge 1 commit into
NVIDIA:mainfrom
abrarshivani:fix/install-packages-nodocs

Conversation

@abrarshivani

@abrarshivani abrarshivani commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Closes #773

What

Pass --nodocs to the dnf install/update calls in the RHEL driver and vGPU Manager images, plus a CI check so a later call can't drop the flag.

Why

The UBI bases don't set tsflags in /etc/dnf/dnf.conf, so every dnf install/dnf update we run writes documentation into the shipped layers. It grows the image and gets flagged by CI scanners — #772 hit this with perl docs containing sample secrets.

The bases themselves are clean, so the docs all come from our own install steps. (rockylinux:9.8-ubi and 10.2-ubi already set tsflags=nodocs; ubi8/9/10 and rocky8 don't.)

Changes

  • rhel8/9/10/Dockerfile: dnf update and the CVE_UPDATES block
  • rhel8/9/10/install.sh: dep_installer and extra_pkgs_install
  • vgpu-manager/rhel8/9/Dockerfile: pciutils and CVE_UPDATES
  • tests/check-nodocs.sh + CI job: fails on any install/update/upgrade/reinstall/downgrade in these files missing --nodocs

module enable, versionlock, config-manager, remove and autoremove are untouched. The check skips rhel*/precompiled, which already persists the setting via config-manager --nodocs --save, and nvidia-driver/ocp_dtk_entrypoint, whose dnf calls run in the started container rather than at image build.

Notes

  • Ubuntu needs no change: its bases ship /etc/dpkg/dpkg.cfg.d/excludes, which already drops /usr/share/doc and /usr/share/man. This is RHEL only.
  • rm -rf /usr/share/doc/* stays. --nodocs doesn't cover files shipped without a %doc marker or written outside rpm.
  • The vGPU Manager images build on nvcr.io/nvidia/cuda:*-base-ubi8/9, which already has documentation in its parent layers. This only stops documentation from the transactions we run.
  • install_weak_deps=False left out: it's what actually kept the perl docs out in avoid installing docs in image #772, but it can silently drop a package needed at runtime. Possible follow up.

Testing

Measured on the CI-built rhel9 images for driver 580.178.04, base 344c1e37 vs branch b102cbcf:

amd64 arm64
before 737,276,803 629,866,665
after 726,017,362 618,596,702
saved 10.74 MiB (1.53%) 10.75 MiB (1.79%)

@abrarshivani
abrarshivani force-pushed the fix/install-packages-nodocs branch 8 times, most recently from aaab24e to a301308 Compare August 4, 2026 02:21
@abrarshivani abrarshivani self-assigned this Aug 4, 2026
@abrarshivani
abrarshivani force-pushed the fix/install-packages-nodocs branch from a301308 to b102cbc Compare August 4, 2026 03:18
@abrarshivani
abrarshivani marked this pull request as ready for review August 4, 2026 03:22
Comment thread tests/check-nodocs.sh Outdated
@rahulait

rahulait commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Thanks @abrarshivani. This change LGTM, lets wait for some time before we merge this PR as we don't want these changes to affect existing release in progress.

The UBI 8/9/10 base images ship almost no documentation of their own, but
they do not set tsflags in /etc/dnf/dnf.conf, so every dnf install and
dnf update we run installs docs and man pages into the layers we ship.
They grow the image for no runtime benefit and get picked up by CI
scanners; NVIDIA#772 hit this when the perl docs pulled in by git were flagged
for containing sample secrets.

Pass --nodocs to the transactional dnf calls in the RHEL driver and vGPU
Manager images, the same way NVIDIA#772 did for git and wget. dnf module enable,
versionlock, config-manager, remove and autoremove are left alone.

Because this relies on the flag being present at each call, add
tests/check-nodocs.sh and run it in CI. It joins continuation lines before
matching, so a command split across lines is still seen as one command,
and splits each command on &&, ||, ; and | so a chain only passes if every
transaction in it carries the flag.

The Ubuntu images need no change: the official ubuntu base images ship
/etc/dpkg/dpkg.cfg.d/excludes, which already excludes /usr/share/doc and
/usr/share/man, so dpkg never writes them.

Signed-off-by: Abrar Shivani <ashivani@nvidia.com>
@abrarshivani
abrarshivani force-pushed the fix/install-packages-nodocs branch from b102cbc to 0e1cf09 Compare August 4, 2026 20:00
@abrarshivani

Copy link
Copy Markdown
Contributor Author

@rahulait Sounds good. Let's merge this after release.

@tariq1890

Copy link
Copy Markdown
Contributor

What is the difference in image size before and after this change?

@abrarshivani

Copy link
Copy Markdown
Contributor Author

What is the difference in image size before and after this change?

@tariq1890 Following are difference in image sizes:

rhel9 images for driver:

amd64 arm64
before 737,276,803 629,866,665
after 726,017,362 618,596,702
saved 10.74 MiB (1.53%) 10.75 MiB (1.79%)

- release-*

jobs:
check-nodocs:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is necessary. If we want to establish a policy of never downloading docs when building images, we could explore that separately. For now, we don't have to add an extra step to our CIs

Comment thread rhel10/Dockerfile
SHELL ["/bin/bash", "-c"]

RUN dnf update -y && dnf clean all
RUN dnf update -y --nodocs && dnf clean all

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we disable docs in a dnf.conf file so that we express this preference once instead of doing so in every dnf command?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[enhancement] : install packages without docs to reduce size and avoid things which are not needed

3 participants