read/write shared folder #348

Open
opened 2025-12-29 00:25:00 +01:00 by adam · 5 comments
Owner

Originally created by @manang on GitHub (Apr 8, 2022).

Hi, I'm trying to add a read/write shared folder. This is my script:

docker run -it \
    --name test \
    --device /dev/kvm \
    -p 50923:10022 \
    -v "${SHARE}:/mnt/hostshare" \
    -e "OSX_COMMANDS=/bin/bash -c \"echo alpine | sudo -S mount_9p hostshare && touch /Volumes/hostshare/xx.txt && ls /Volumes/ho>
    -e EXTRA="-virtfs local,path=/mnt/hostshare,mount_tag=hostshare,security_model=passthrough,id=hostshare" \
     -v "${PWD}/mac_hdd_ng_auto_big_sur.img:/image" \
      sickcodes/docker-osx:naked-auto

Mac os Can read, but it can't write on /Volumes/hostshare.
How can I add the grants to write data on the volume?
Thanks

Angelo

Originally created by @manang on GitHub (Apr 8, 2022). Hi, I'm trying to add a read/write shared folder. This is my script: ``` docker run -it \ --name test \ --device /dev/kvm \ -p 50923:10022 \ -v "${SHARE}:/mnt/hostshare" \ -e "OSX_COMMANDS=/bin/bash -c \"echo alpine | sudo -S mount_9p hostshare && touch /Volumes/hostshare/xx.txt && ls /Volumes/ho> -e EXTRA="-virtfs local,path=/mnt/hostshare,mount_tag=hostshare,security_model=passthrough,id=hostshare" \ -v "${PWD}/mac_hdd_ng_auto_big_sur.img:/image" \ sickcodes/docker-osx:naked-auto ``` Mac os Can read, but it can't write on /Volumes/hostshare. How can I add the grants to write data on the volume? Thanks Angelo
Author
Owner

@manang commented on GitHub (Apr 13, 2022):

I want to add that my vm user has, as uuid, 1001, the uid of the user in the docker image is 1000. I tried to change the uid of the mac os user from 501 to 1001, but no way, I can't write on the shared volume.
Do you have any hint?

@manang commented on GitHub (Apr 13, 2022): I want to add that my vm user has, as uuid, 1001, the uid of the user in the docker image is 1000. I tried to change the uid of the mac os user from 501 to 1001, but no way, I can't write on the shared volume. Do you have any hint?
Author
Owner

@sickcodes commented on GitHub (Apr 17, 2022):

https://github.com/sickcodes/Docker-OSX#share-folder-with-docker-osx-qemu-macos

There are other options such as NFS which might be substantially easier: https://github.com/sickcodes/Docker-OSX#share-linux-nfs-drive-into-macos

@sickcodes commented on GitHub (Apr 17, 2022): https://github.com/sickcodes/Docker-OSX#share-folder-with-docker-osx-qemu-macos There are other options such as NFS which might be substantially easier: https://github.com/sickcodes/Docker-OSX#share-linux-nfs-drive-into-macos
Author
Owner

@manang commented on GitHub (Apr 21, 2022):

Hi, thanks for your answer. the problem is that the uid of the user of mac os has to be the same to the user in the docker instance and to the user in the host vm.
so, in the first link I can setup a read folder, but not a write folder.
I'm trying with the second

@manang commented on GitHub (Apr 21, 2022): Hi, thanks for your answer. the problem is that the uid of the user of mac os has to be the same to the user in the docker instance and to the user in the host vm. so, in the first link I can setup a read folder, but not a write folder. I'm trying with the second
Author
Owner

@ugurcan377 commented on GitHub (Jun 17, 2022):

I was having the same problem, was able create and write to files, but unable to create new directories and such. I managed to fix it with changing the security_model of the -virtfs from passthrough to none. QEMU documentation explains the differences like this

passthrough: Files are stored using the same credentials as they are created on the guest. This requires QEMU to run as root.
none: Same as "passthrough" except the sever won't report failures if it fails to set file attributes like ownership (chown). This makes a passthrough like security model usable for people who run kvm as non root.

After this change I was able to create directories within the shared folder.

@ugurcan377 commented on GitHub (Jun 17, 2022): I was having the same problem, was able create and write to files, but unable to create new directories and such. I managed to fix it with changing the `security_model` of the `-virtfs` from `passthrough` to `none`. QEMU documentation explains the differences like this >passthrough: Files are stored using the same credentials as they are created on the guest. This requires QEMU to run as root. none: Same as "passthrough" except the sever won't report failures if it fails to set file attributes like ownership (chown). This makes a passthrough like security model usable for people who run kvm as non root. After this change I was able to create directories within the shared folder.
Author
Owner

@sickcodes commented on GitHub (Jun 20, 2022):

The easiest way is using sshfs over the network; you get read write to the whole disk

@sickcodes commented on GitHub (Jun 20, 2022): The easiest way is using sshfs over the network; you get read write to the whole disk
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/Docker-OSX#348