fix bind-mount failure on macOS Docker Desktop#2021
fix bind-mount failure on macOS Docker Desktop#2021ericcurtin wants to merge 1 commit into89luca89:mainfrom
Conversation
|
I didn't notice this before because during development was using my git repo which is in $HOME |
65f34c7 to
fdeabc9
Compare
|
Would it make sense to have this logic as a pre-flight check in EDIT: or maybe we can fix it on brew tap to contextually install it to ~/.local/bin too (or only there) |
|
What about a hard link? Then we never go stale, because the same file is shared |
If it works on macos like it works on linux I suppose yes, cp should preserve inode number. |
|
Regarding the hard link idea: it might be risky because Homebrew updates often replace the file (creating a new inode), which would leave the hard link pointing to a stale/orphaned version of the script. What if we treat ~/.local/share/distrobox/ as a managed cache?
For uninstalls, it does leave a small footprint, but that's fairly standard for macOS CLI tools. We could just document it or add a cleanup flag to distrobox-rm. This keeps the logic centralized and avoids the VirtioFS mount issues entirely. |
Agree, it should be in one entry point and should handle staleness |
fdeabc9 to
5fe219e
Compare
Docker Desktop on macOS only shares specific directories with its Linux VM via VirtioFS ($HOME, /private, /Volumes, /tmp). Scripts installed to /usr/local/bin (e.g. via Homebrew) are not accessible, so Docker creates an empty directory placeholder in the VM. This makes /usr/bin/entrypoint a directory in the container, causing runc to fail with "is a directory". distrobox-create: on Darwin, copy distrobox-init, distrobox-export, and distrobox-host-exec to ~/.local/share/distrobox/ (always under $HOME, always VirtioFS-shared) before using them as bind-mount sources. distrobox-enter: the self-healing detection code reads .HostConfig.Binds, which Docker Desktop returns with a /host_mnt prefix (the VM's view of the VirtioFS mount). Strip this prefix on Darwin before checking file existence, preventing a spurious "mkdir: /host_mnt: Read-only file system" crash even for correctly-created containers. Signed-off-by: Eric Curtin <eric.curtin@docker.com>
5fe219e to
efb3f36
Compare
|
@89luca89 made another change, let me know what you think |
|
My biggest worry about only putting the scripts in ~/.local/ in thing's like this won't "just work" curl -s https://raw.githubusercontent.com/89luca89/distrobox/main/install | sudo sh |
Docker Desktop on macOS only shares specific directories with its Linux VM via VirtioFS ($HOME, /private, /Volumes, /tmp). Scripts installed to /usr/local/bin (e.g. via Homebrew) are not accessible, so Docker creates an empty directory placeholder in the VM. This makes /usr/bin/entrypoint a directory in the container, causing runc to fail with "is a directory".
distrobox-create: on Darwin, copy distrobox-init, distrobox-export, and distrobox-host-exec to ~/.local/share/distrobox/ (always under $HOME, always VirtioFS-shared) before using them as bind-mount sources.
distrobox-enter: the self-healing detection code reads .HostConfig.Binds, which Docker Desktop returns with a /host_mnt prefix (the VM's view of the VirtioFS mount). Strip this prefix on Darwin before checking file existence, preventing a spurious "mkdir: /host_mnt: Read-only file system" crash even for correctly-created containers.