Skip to content

DL3009: Allow either cache or tmpfs mounts#1123

Merged
m-ildefons merged 3 commits intohadolint:masterfrom
m-ildefons:gh-1095
Sep 11, 2025
Merged

DL3009: Allow either cache or tmpfs mounts#1123
m-ildefons merged 3 commits intohadolint:masterfrom
m-ildefons:gh-1095

Conversation

@m-ildefons
Copy link
Copy Markdown
Member

Allow apt cache and lists directories to be either cache or tmpfs mounts without warning.

DL3009 warns if apt cache or list data is kept unnecessarily in the container image, as this increases the image size. There are several ways to avoid this: 1) remove the cache and lists directories after use, 2) mount a cache from the host to these directories and 3) mount a tmpfs from the host to the directories. This change modifies the DL3009 rule such that it won't trigger a warning if the a mount of type tmpfs is used for either the cache or lists directory.

related-to: #1095

Allow apt cache and lists directories to be either cache or tmpfs mounts
without warning.

DL3009 warns if apt cache or list data is kept unnecessarily in the
container image, as this increases the image size.
There are several ways to avoid this: 1) remove the cache and lists
directories after use, 2) mount a cache from the host to these
directories and 3) mount a tmpfs from the host to the directories.
This change modifies the DL3009 rule such that it won't trigger a
warning if the a mount of type tmpfs is used for either the cache or
lists directory.

related-to: hadolint#1095

Signed-off-by: Moritz Röhrich <moritz@ildefons.de>
@m-ildefons m-ildefons self-assigned this Sep 9, 2025
@m-ildefons
Copy link
Copy Markdown
Member Author

@detly would you like to review this?

Allow cache and tmpfs mounts to avoid triggering rules DL3019, DL3060,
DL3042, DL3040

For all package managers, the same applies: if the `RUN` instruction has
a cache or tmpfs mount at the location where the package manager may
keep its temporary files (caches, repo metadata etc.), then the rules
warning about cache data being included in the container image should
not trigger.

related-to: hadolint#983
related-to: hadolint#497

Signed-off-by: Moritz Röhrich <moritz@ildefons.de>
- reduce duplication
- remove unnecessary imports
- remove unnecessary brackets and braces
- eta reduce

Signed-off-by: Moritz Röhrich <moritz@ildefons.de>
@detly
Copy link
Copy Markdown

detly commented Sep 11, 2025

@detly would you like to review this?

Thanks for asking! Sorry for the delay, I was on leave.

I don't know Haskell, but I can confirm that the additional tests cover my own usage of it.

@m-ildefons
Copy link
Copy Markdown
Member Author

👍 thanks.

@m-ildefons m-ildefons merged commit 9c9d3f8 into hadolint:master Sep 11, 2025
2 checks passed
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.

Do not report DL3042 if cache mount is used False positive DL3042

2 participants