Search code examples
dockerdocker-composedocker-for-mac

With Docker for Mac when using :cached bind mounts, are the delays on the host or the container?


The osxfs caching page, section delegated reads:

For directories mounted with delegated the container’s view of the file system is authoritative, and writes performed by containers may not be immediately reflected on the host file system.

section cached reads:

For directories mounted with cached, the host’s view of the file system is authoritative; writes performed by containers are immediately visible to the host, but there may be a delay before writes performed on the host are visible within containers.

This is unclear to me. If, using cached, the host's view of the system is authoritative, shouldn't that mean that if something changes on the host, it will be immediately reflected in the container? Why is the delay on the "authoritative" side?


Solution

  • In :cached mode reads of file attributes and file contents are cached by the containers with a long lifetime. When the content changes on the host a cache invalidation message is immediately sent to the containers to expire the cache entries -- this is quick but it isn't instantaneous. The documentation is talking about this delay.