I apologize for the incomplete bug report, and I want to thank for the time you all have invested. I will be more precise below:
MBPro: M4 Max w/ 36GB. Sequioa 15.5
Docker Desktop: Version 4.40.0 (187762), Engine: 28.0.4, Compose: v2.34.0-desktop.1, Credential Helper: v0.9.3, Kubernetes: v1.32.2
Virtualization: Apple vIrtualization, using rosetta, and virtioFS
experiment.
- This will create the log file and start the tail.
> sudo touch /var/log/johan.log
> sudo chmod ugo+w /var/log/johan.log
> echo line 1 >> /var/log/johan.log
> echo line 2 >> /var/log/johan.log
> docker run --rm -it -v /var/log/:/var/hostlog:ro debian:bookworm tail -f /var/hostlog/johan.log
line 1
line 2
I leave the docker run running, and I will report any updates to the tail -f
- I also tail the file in another host window: (note the path
/var/log/johan.log(host) vs/var/hostlog/johan.log(container)). and leave this running.
> tail -f /var/log/johan.log
line 1
line 2
- In a third window, I will add some lines to the host log file.
> echo "line 3" >> /var/log/johan.log
> echo "line 4" >> /var/log/johan.log
These were immediately reported by both the host and container tails. HRM.
- Adding some more lines, but without closing the file between each (so like a logger)
> cat >> /var/log/johan.log
line5
lines 6
these are shown in the host, but not the container
So here we see the difference. When catting lines but without closing the file, the host tail -f immediately echoes each line as it is ENTERed (I mean pressing enter), and presumably flushed by some part of the OS / cat. But the container tail -f sees nothing until I exit the cat, and the file is closed. Then it sees all the lines added by the cat. (“line5 … not the container”)
So it seems like whatever mechanism docker deskop uses to propagate files will notice “file close” but not “flush”. And presumably the ls -l somehow emits a similar event.
I wonder if this is bug, something I can fix with better usage pattern, or working as intended
hope that helps!