Hello, I’m experiencing a very unusual problem when using VirtioFS with the Apple Virtualization Framework and Docker, through tools such as Lima and Tart.
I’ve described the full details here: lima-vm/lima#4053 (comment), but here’s a quick summary.
Steps to Reproduce
Given a directory structure like this:
mkdir -p local-test-dir/dir
and running the following command:
docker run -u $(id -u) --rm -v $PWD/dir:/mnt/dir alpine:latest sh -c "ls -al /mnt"
the output is:
total 8
drwxr-xr-x 1 root root 4096 Sep 23 22:48 .
drwxr-xr-x 1 root root 4096 Sep 23 22:48 ..
drwxr-xr-x 2 root root 64 Sep 19 21:34 dir # <-- INCORRECT
The directory appears as root:root, which is wrong.
Workaround
If I add an artificial sleep of more than 0.9s before listing the directory, the issue disappears:
docker run -u 501 --rm -v $PWD/dir:/mnt/dir alpine:latest sh -c "sleep 0.9; ls -al /mnt"
Output:
total 8
drwxr-xr-x 1 root root 4096 Sep 23 22:48 .
drwxr-xr-x 1 root root 4096 Sep 23 22:48 ..
drwxr-xr-x 2 501 root 64 Sep 19 21:34 dir # <-- CORRECT
When using an interactive shell inside the container, the ownership always looks correct, likely because the delay between typing commands gives the system enough time.
Observations
The issue is not present on Docker Desktop or OrbStack, which may be due to their custom VirtioFS implementations.
I reproduced the problem across multiple environments, Linux distributions, and Docker versions.
The problem occurs on macOS 15 and 16.
Based on my testing, this seems to be a bug in the VirtioFS implementation in the macOS kernel.
Topic:
App & System Services
SubTopic:
Core OS
Tags: