Describe the bug
Renaming a directory that was created during docker build (i.e., a directory in an overlay2 lower layer) inside an OrbStack container fails with EXDEV (Invalid cross-device link) at runtime. This does not occur with Docker Desktop, causing OrbStack to not be fully drop-in compatible for builds or apps expecting to rename such directories. The error seems related to kernel overlay2 settings and btrfs as the backing filesystem.
Impact: Any application that calls rename() on a directory created during image build will fail at runtime. As a real-world example, GitLab's scripts/regenerate-schema renames db/migrate/ temporarily and fails on OrbStack but works on Docker Desktop.
To Reproduce
- Create the following Dockerfile:
FROM debian:bookworm-slim
RUN mkdir -p /test/mydir && touch /test/mydir/file.txt
CMD ["bash", "-c", "mv /test/mydir /test/mydir__ && echo 'rename OK' && mv /test/mydir__ /test/mydir"]
- Run:
docker build -t exdev-test .
docker run --rm exdev-test
Expected: "rename OK"
Actual: mv: cannot move '/test/mydir' to '/test/mydir__': Invalid cross-device link
Alternatively, this fails in Ruby as well:
File.rename("/test/mydir", "/test/mydir__")
# => Errno::EXDEV: Invalid cross-device link
Environment:
- OrbStack kernel: 6.17.8-orbstack-00308-g8f9c941121b1
- Host: macOS (Apple Silicon)
- Overlay parameters: redirect_dir = N, metacopy = N, redirect_always_follow = Y
- Backing filesystem: btrfs
Expected behavior
Directories created during image build should be able to be renamed at runtime in containers running under OrbStack, matching behavior of Docker Desktop (using the same overlay2 kernel settings, but with ext4 backing FS), so that tools and scripts remain compatible.
Diagnostic report (REQUIRED)
No response
Screenshots and additional context (optional)
Analysis:
OrbStack's kernel overlay2 module has redirect_dir=N. The Linux kernel cannot rename directories that reside in a lower overlay layer and returns EXDEV unless the redirect_dir feature is enabled. While Docker Desktop also has redirect_dir=N, it does not show this error—possibly due to its use of ext4 (vs btrfs on OrbStack) as the backing filesystem or a difference in how its LinuxKit kernel handles this case.
References:
Possible fix:
- Enable
redirect_dir=on in OrbStack's kernel config (aware of diff driver tradeoff)
- Or replicate the workaround/behavior from Docker Desktop's kernel
Describe the bug
Renaming a directory that was created during
docker build(i.e., a directory in an overlay2 lower layer) inside an OrbStack container fails withEXDEV(Invalid cross-device link) at runtime. This does not occur with Docker Desktop, causing OrbStack to not be fully drop-in compatible for builds or apps expecting to rename such directories. The error seems related to kernel overlay2 settings and btrfs as the backing filesystem.Impact: Any application that calls rename() on a directory created during image build will fail at runtime. As a real-world example, GitLab's scripts/regenerate-schema renames db/migrate/ temporarily and fails on OrbStack but works on Docker Desktop.
To Reproduce
docker build -t exdev-test . docker run --rm exdev-testExpected: "rename OK"
Actual:
mv: cannot move '/test/mydir' to '/test/mydir__': Invalid cross-device linkAlternatively, this fails in Ruby as well:
Environment:
Expected behavior
Directories created during image build should be able to be renamed at runtime in containers running under OrbStack, matching behavior of Docker Desktop (using the same overlay2 kernel settings, but with ext4 backing FS), so that tools and scripts remain compatible.
Diagnostic report (REQUIRED)
No response
Screenshots and additional context (optional)
Analysis:
OrbStack's kernel overlay2 module has
redirect_dir=N. The Linux kernel cannot rename directories that reside in a lower overlay layer and returnsEXDEVunless theredirect_dirfeature is enabled. While Docker Desktop also hasredirect_dir=N, it does not show this error—possibly due to its use of ext4 (vs btrfs on OrbStack) as the backing filesystem or a difference in how its LinuxKit kernel handles this case.References:
redirect_dirand EXDEVPossible fix:
redirect_dir=onin OrbStack's kernel config (aware of diff driver tradeoff)