'Does docker cache files/directories? If so, is it possible to force it to refresh its cache?

Anyone know if Docker somehow caches files/file systems? And if it does, is there a way to suppress that or force it to regenerate/refresh the cache. I am editing my files outside my docker image, but the directory inside the docker image doesn't seem to include them in it. However, outside the docker image the "same" directory does include the files. The only thing that makes sense to me is that docker has an internal "copy" of the directory and isn't going to the disk, so it sees an outdated copy of the directory before the file was added.

Details: I keep my "work" files in a directory on a separate partition (/Volumes/emacs) on my MacBook, i.e.:

/Volumes/emacs/datapelago

I do my editing in emacs on the MacBook, but not in the docker container. I have a link to that directory called:

/projects

And I might edit or create a file called:

/projects/nuc-440/qflow/ToAttribute.java

In the meantime I have a docker container I created this way:

docker container create -p 8080:8080 -v /Volumes/emacs/datapelago:/projects -v /Users/christopherfclark:/Users/cfclark --name nuc-440 gradle:7.4.2-jdk17 tail -f /dev/null 

I keep a shell running in that container:

docker container exec -it nuc-440 /bin/bash
cd /projects/nuc-440

And after making changes I run the build/test sequence:

gradle clean;gradle build;gradle test

However, recently I have noticed that when I make changes, add files, they don't always get reflected inside the docker container, which of course can cause the build to fail or the test not to pass etc.

Thus, this question.

I'd rather not have to start/stop the container each time and instead just keep it running and tell it to "refetch" the projects/nuc-440 directory and its children.


I restarted the docker container and it is now "tracking" file changes again. That is I can make changes in MacOS and they are reflected inside docker with no additional steps. I don't seem to have to continually restart it. It must have gotten into a "wierd" state. However, I don't have any useful details beyond that. Sorry.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source