-
Notifications
You must be signed in to change notification settings - Fork 120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
VirtioFS: File size in bind mounted volume does not match host #7501
Comments
Hello, On top of what @lorenzodalaqua said, I encountered a strange issue where files where not truncated, but changes in files done on my IDE was not directly reflected in the docker container (I have a flask app with gunicorn that should reload on file changes, but no reload was happening after modifying the code). |
Checking in with the same problem. MacOS Sequoia 15.1.1, 2021 M1 Max. I suspected this might be something related to inotify and/or atomic save; the issue is persistent across Sublime Text and VSCode, but intermittent when files are edited with vim. 🤷 docker info
docker version
|
Description
This might have some similarity to issue #7494.
The development setup where I work uses a project volume shared by multiple containers. The volume is also bind mounted to a directory on the host using mount options:
This has worked fine in Docker Desktop on Mac, using VirtioFS (and the "Apple Virtualization Framework"), with Docker Desktop up until version 4.32. The volume is synced any host file changes due to being bind mounted.
When upgrading to version 4.33 we started having issues with files being "truncated" when accessed by containers when there are changes to the file on the host. The contents are updated on the container, but do not fully match the host.
For example, a file with contents:
ABCDEFG
on the host, after adding some characters to it, (e.g. making the contents123ABCDEFG
), when accessed by the container through the volume, will be truncated (e.g.123ABCD
), with the amount of characters added being absent at the end of the file.By checking with
ls
on both the container and host, I was able to determine the file size is not updated correctly on the volume, but the contents are.Looking at this comment on the issue I referenced above, I suspect this might also be related to VirtioFS cache invalidation not being triggered. If I run this sequence of commands from inside a container mounting the volume:
Anyway, I was able to reproduce it consistently with the following script:
Reproduce
Expected behavior
The file in the bind mounted volume should match the file on the host on every change.
docker version
Client: Version: 27.3.1 API version: 1.47 Go version: go1.22.7 Git commit: ce12230 Built: Fri Sep 20 11:38:18 2024 OS/Arch: darwin/arm64 Context: desktop-linux Server: Docker Desktop 4.36.0 (175267) Engine: Version: 27.3.1 API version: 1.47 (minimum version 1.24) Go version: go1.22.7 Git commit: 41ca978 Built: Fri Sep 20 11:41:19 2024 OS/Arch: linux/arm64 Experimental: false containerd: Version: 1.7.21 GitCommit: 472731909fa34bd7bc9c087e4c27943f9835f111 runc: Version: 1.1.13 GitCommit: v1.1.13-0-g58aa920 docker-init: Version: 0.19.0 GitCommit: de40ad0
docker info
Diagnostics ID
4EB0271E-BBC1-4A04-87BB-E7F66581011B/20241210141531
Additional Info
This behavior happened only with VirtioFS, the same setup when run with the "osxfs (Legacy)" file sharing implementation had no issues.
This might be of note: when I attempted running the same reproduction script above with the "Docker VMM (Beta)" Virtual Machine Manager, the file is never updated on the volume after changes on the host, it was not corrupted/truncated, it is just never updated.
The text was updated successfully, but these errors were encountered: