1

I am looking for a way to create a new mount point for a directory similar to the mount --bind command in Linux.

In Linux, mount --bind creates a so-called bind mount which takes an existing directory tree and replicates it under a different point. The directories and files in the bind mount are the same as the original. Any modification on one side is immediately reflected on the other side, since the two views show the same data.

A symlink won't work because I'm working with Docker and Docker disallows symlinks when building images from a Dockerfile. I prefer solutions that work on macOS Sonoma.

2
  • 2
    macOS doesn‘t support this. Can‘t you refer your actual directory tree from the Dockerfile?
    – nohillside
    Commented Sep 19 at 8:11
  • No. Docker does not allow that. You may only reference directories that are within the "build context". Commented Sep 19 at 13:51

2 Answers 2

2

Have you tried bindfs yet? I believe it may be what you’re hunting.

MacPorts packages bindfs going all the way back to macOS Sierra. It depends on macfuse, which MacPorts also packages.

2
  • Do you use bindfs with fuse-t or a different user space software on macOS? If you can list version numbers that’s even much better since not everyone may be on macOS Sonoma.
    – bmike
    Commented Sep 19 at 12:43
  • I haven't been able to find bindfs for MacOS. The only bindfs in homebrew is Linux-only. I do have MacFuse installed. Do you know where I can get bindfs for Mac? Commented Sep 19 at 13:39
1

I was able to solve this with a slight variation on @jaburro's answer. I don't use MacPorts. I use Homebrew instead. Homebrew does have MacFuse and it installs without incident. Unfortunately, the only version of bindfs Homebrew has is linux-only.

The solution was to build bindfs from source.

  • Install Xcode with developer tools
  • Download the source tarball from the bindfs.org site
  • Unpack the tarball
  • Install dependencies to build bindfs and build and install it.
cd <bindfs source dir>
brew install macfuse
brew install pkg-config
./configure
make
sudo make install

A couple of caveats:

  • You must be in zsh when you run ./configure, make, and make install or the scripts will fail
  • You will have to reboot after the install
  • You will have to enable a couple of things in settings

Oh, and this did allow me to create a mount point in my build context directory and copy the files from it to the image.

1
  • If true, I'd call the build requiring zsh a bug, the included scripts all call out either /bin/sh or /bin/bash. All of them seem to have included shbangs. Glad it works, though. Commented Sep 21 at 15:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .