I am quite familiar with the Ack source code. (I've been bug-fixing lately.)
It uses OS Filesystem caching only, and doesn't care about timestamps. At all.
No secret meta-data cache.
(Andy and I contemplated the tradeoffs of hypothetically having a pre-scan mode to collect meta-data and keywords ala CTAGS for performance. This present discussion is a demonstration why that would cause more obscure problems than it solves.)
If you are seeing caching favoring host over container and vice versa alternating, this suggests your host is releasing it's FS Cache when the container gets busy and vice versa. Which paradoxically may be beneficial.
OS FS caching is generally well understood. Some small but significant % of RAM is used for filesystem block shadowing, on the assumption that recent files read or written may get read or written again soon. These are discarded on the LRU algorithm, to be re-used either for a different file block from the next read/write, or because some process requests more RAM. A happy POSIX system has most of its free memory full of quite a history of read (& written) file blocks [including inode etc. but data too] and very little in fully "free" state [ready to be assigned in interrupt level].
Starting a Container likely burns through much of the cached block space in the process of reserving RAM for the container and reading/populating the container image. Whether the Container's FS cache is shared with the Host FS cache depends on how heavy or light weight a Container implementation is, I would guess. For lightweight, one might expect the Container FS to be a thin alias layer over the host OS FS, so that cache would be shared. For heavyweight, they may have to flush each other's caches in order to avoid inconsistencies.
Ack is not performance optimized; it provides a pure-Perl file-type-aware-DWIM interactive enhancement for programmers doing maintenance/reverse-engineering; and guarantees that the Perl RegEx syntax is exactly what your current running Perl has, an advantage for those of us living on the bleading edge (and changeable by 'perlbrew switch'). With a reasonable size code tree on a solid-state drive or with FS caching already primed, Ack doesn't need more caching than OS filesystem caching for acceptable human interactive performance.
[If you didn't upgrade to NVME 'disks' before the AI bubble sent prices through the roof, I'm so sorry. It is possible to configure a small NVME as cache for a larger spinning rust drive ... which is even built into some modern rust drives.]
[I have some subtrees that try my patience with Ack, but they're absurd, and that's on me! But finger-memory is strong, so I don't switch to a faster equivalent tool; when I need something else, I have a retrieval index (swish-e swish-search) that does intensive indexing. But that's offlabel uses of both tools.]
For performance critical uses, good old GNUutils grep (with -P 'PerlRE' nowadays) is hard to beat, and to be preferred if the Container is an automation.
[AFAIK *BSD (incl.Mac) grep doesn't have -P, they keep it in a separate pcregrep command; and likely BusyBox doesn't at all.
Canonical's uutils Rust reimplementation has -P already :wow: .]
There are several other projects inspired by Ack (on the More Tools [
https://beyondgrep.com/more-tools/] and Comparison [
https://beyondgrep.com/feature-comparison/] tabs of the website) that are quite fast and
nearly as Perl compatible in their PCRE RegExes as Ack, if speed is what you need. Imitation is the sincerest form of flattery, we consider them friends and are happy to recommend them when Ack's lack of performance becomes a factor for someone.