darwin-containers / rund

OCI Container Runtime for Darwin
Apache License 2.0
432 stars 13 forks source link

Volume mounts #14

Closed jlsalmon closed 9 months ago

jlsalmon commented 9 months ago

Edit: apologies if this is the wrong repo to ask this on.

Hello,

First off, massive congratulations for all your work on this so far 🎉

Question: is it currently possible to mount volumes from the host into macOS containers via -v? I didn’t see it explicitly mentioned, so maybe it just works or maybe it’s a future thing.

Thanks in advance!

slonopotamus commented 9 months ago

Good question. They were supposed to Just Work, but now my testing shows that they don't!

Investigating what went wrong...

slonopotamus commented 9 months ago

Fixed in rund 0.0.2 + dockerd 0.0.2. If you already installed those packages from homebrew-formula, you can brew update && brew upgrade && sudo brew services restart dockerd to get update.

jlsalmon commented 9 months ago

Awesome, thanks @slonopotamus, I’ll try it out!

jlsalmon commented 9 months ago

Hmm possibly I don't have something set up correctly? (macOS 14 (Sonoma), dockerd 0.0.2, rund 0.0.2, containerd 0.0.1)

Working without volume mount:

docker run --rm -it ghcr.io/macoscontainers/macos-jail/ventura:latest ls -al /etc
WARNING: The requested image's platform (unknown) does not match the detected host platform (darwin/arm64/v8) and no specific platform was requested
total 16
drwxr-xr-x   5 root  staff  160 Sep 27 05:44 .
drwxr-xr-x  10 root  staff  320 Sep 27 05:44 ..
-rw-r--r--   1 root  staff  230 Jul 28 15:10 hosts
-rw-r--r--   1 root  staff  357 Jul 28 15:10 resolv.conf
drwxr-xr-x   6 root  wheel  192 Sep 27 05:44 ssl

Fails with volume mount:

docker run --rm -it -v /tmp:/etc/tmp ghcr.io/macoscontainers/macos-jail/ventura:latest ls -al /etc
WARNING: The requested image's platform (unknown) does not match the detected host platform (darwin/arm64/v8) and no specific platform was requested
docker: Error response from daemon: failed to create task for container: failed to create shim task: failed to mount rootfs component: bindfs [[/tmp /private/d/vfs/edd4d567227cc39e4cfeb4071218d0c97a82caa94d85489909d1e07b7103c7b1/etc/tmp]] failed: "Failed to resolve mount point `/private/d/vfs/edd4d567227cc39e4cfeb4071218d0c97a82caa94d85489909d1e07b7103c7b1/etc/tmp': No such file or directory\n": exit status 1: unknown.
jlsalmon commented 9 months ago

Oh, it looks like the leaf directory needs to already exist. I found an empty directory in the container and it works:

docker run --rm -it -v /tmp:/etc/ssl/certs ghcr.io/macoscontainers/macos-jail/ventura:latest ls -al /etc/ssl/certs
WARNING: The requested image's platform (unknown) does not match the detected host platform (darwin/arm64/v8) and no specific platform was requested
total 24
drwxrwxrwt@ 4 root        wheel  128 Sep 27 04:31 .
drwxr-xr-x  6 root        wheel  192 Sep 27 05:55 ..
drwx------  3 gitlab-bot  wheel   96 Sep 27 04:31 com.apple.launchd.z626qD94iW
drwxr-xr-x  2 root        wheel   64 Sep 27 04:31 powerlog
slonopotamus commented 9 months ago

Uh. Let's reopen. Not sure yet which part of this whole mess is supposed to create directory :D

slonopotamus commented 9 months ago

Fixed in rund-0.0.3, now full directory hierarchy for bind mount target directory is created inside container. Just brew update && brew upgrade.