abiosoft / colima

Container runtimes on macOS (and Linux) with minimal setup
MIT License
17.73k stars 364 forks source link

APFS Volume not correctly mounting in docker container #1051

Closed nnathan closed 1 week ago

nnathan commented 1 week ago

Description

Volume mount working with default system volume:

c2:code $ df -h .
Filesystem      Size    Used   Avail Capacity iused ifree %iused  Mounted on
/dev/disk3s5   926Gi   636Gi   269Gi    71%    2.0M  2.8G    0%   /System/Volumes/Data
c2:code $ docker run -it --mount type=bind,src=$PWD,dst=/model ubuntu
root@9daa7afabc1d:/# cd /model/
root@9daa7afabc1d:/model# ls
DocExample.pdf          frr                             musl                         spiped
  .
  .
  .
root@9daa7afabc1d:/# mount | grep -i model
mount0 on /model type virtiofs (rw,relatime)

Volume mount not working using a separate volume mount (case sensitive volume):

c2:landingnet $ df -h .
Filesystem      Size    Used   Avail Capacity iused ifree %iused  Mounted on
/dev/disk3s7   926Gi   1.5Gi   269Gi     1%     21k  2.8G    0%   /Volumes/s
c2:landingnet $ docker run -it --mount type=bind,src=$PWD,dst=/model ubuntu
root@8b715762cba0:/# cd /model/
root@8b715762cba0:/model# ls
root@8b715762cba0:/model# mount | grep -i model
/dev/vda1 on /model type ext4 (rw,relatime,discard,errors=remount-ro,commit=30)

Version

c2:colima $ colima version && limactl --version && qemu-img --version
colima version 0.6.9
git commit: c3a31ed05f5fab8b2cdbae835198e8fb1717fd0f

runtime: docker
arch: aarch64
client: v26.1.3
server: v26.1.1
limactl version 0.22.0
qemu-img version 9.0.1
Copyright (c) 2003-2024 Fabrice Bellard and the QEMU Project developers

Operating System

Output of colima status

c2:colima $ colima status
INFO[0000] colima is running using macOS Virtualization.Framework
INFO[0000] arch: aarch64
INFO[0000] runtime: docker
INFO[0000] mountType: virtiofs
INFO[0000] socket: unix:///Users/naveen/.colima/default/docker.sock

Reproduction Steps

  1. Use Disk Utility to create an APFS Volume
  2. Run docker run -it -v /Volume/${VOLUME_NAME}:/model ubuntu
  3. Check mount | grep model, if it shows up as ext4 then the volume mount didn't work and the volume mountpoint is empty.

Expected behaviour

Expect the volume mount point to be populated with whatever is on the host filesystem and not empty.

Additional context

No response

nnathan commented 1 week ago

I have an inkling that this is probably a permissions / restriction of mounting from /Volumes/** in Docker. I just don't know how to interrogate the list of directories that are allowed to be mounted. Would appreciate some assistance.

nnathan commented 1 week ago

Issue resolved thanks to the explanation in https://github.com/abiosoft/colima/issues/515.

Just had to add the mountpoint in the colima.yaml:

mounts:
  - location: /Volumes/myvol
    writable: true