Copy files from Host into container User Folder ? #166

Open
opened 2025-12-29 00:19:07 +01:00 by adam · 6 comments
Owner

Originally created by @mhabsaoui on GitHub (Apr 12, 2021).

Hi,

Just wanted to know if possible to mount host files into running docker container, e.g. inside the directory "/Users/$USER/Documents" ?

Of course the the -v volume option is made for that, but when going through docker container content ( docker exec -it docker-osx bash ), I don't seem to find my $USER home folder...

Is there anay Copy/Paste from Host to OSX setting on the Machine (like with virtuqlbox) ?

image

Thanks for feedback...

Originally created by @mhabsaoui on GitHub (Apr 12, 2021). Hi, Just wanted to know if possible to mount host files into running docker container, e.g. inside the directory "/Users/$USER/Documents" ? Of course the the -v volume option is made for that, but when going through docker container content ( `docker exec -it docker-osx bash` ), I don't seem to find my $USER home folder... Is there anay Copy/Paste from Host to OSX setting on the Machine (like with virtuqlbox) ? ![image](https://user-images.githubusercontent.com/18755135/114380471-69567d00-9b8a-11eb-80a5-6eb6e2ae0806.png) Thanks for feedback...
adam added the enhancementdocumentationhelp wanted labels 2025-12-29 00:19:07 +01:00
Author
Owner

@sickcodes commented on GitHub (Apr 16, 2021):

Try over network

scp -P 50922 file.pdf user@localhost:/Users/user/Documents

Or by sharing a directory between you and the OSX

# stat mac_hdd_ng.img
SHARE=/home/user/test/1px/

docker run -it \
    --device /dev/kvm \
    -p 50922:10022 \
    -v /tmp/.X11-unix:/tmp/.X11-unix \
    -e "DISPLAY=${DISPLAY:-:0.0}" \
    -v "${PWD}/mac_hdd_ng.img:/home/arch/OSX-KVM/mac_hdd_ng.img" \
    -v "${SHARE}:/mnt/hostshare" \
    -e OSX_COMMANDS="echo alpine | sudo -S mount_9p hostshare && /bin/bash" \
    -e EXTRA="-virtfs local,path=/mnt/hostshare,mount_tag=hostshare,security_model=passthrough,id=hostshare" \
    sickcodes/docker-osx:auto

If you aren't using :auto

You can mount the folder by using the command mount_9p hostshare when you are in side the guest

@sickcodes commented on GitHub (Apr 16, 2021): Try over network ```bash scp -P 50922 file.pdf user@localhost:/Users/user/Documents ``` Or by sharing a directory between you and the OSX ```bash # stat mac_hdd_ng.img SHARE=/home/user/test/1px/ docker run -it \ --device /dev/kvm \ -p 50922:10022 \ -v /tmp/.X11-unix:/tmp/.X11-unix \ -e "DISPLAY=${DISPLAY:-:0.0}" \ -v "${PWD}/mac_hdd_ng.img:/home/arch/OSX-KVM/mac_hdd_ng.img" \ -v "${SHARE}:/mnt/hostshare" \ -e OSX_COMMANDS="echo alpine | sudo -S mount_9p hostshare && /bin/bash" \ -e EXTRA="-virtfs local,path=/mnt/hostshare,mount_tag=hostshare,security_model=passthrough,id=hostshare" \ sickcodes/docker-osx:auto ``` If you aren't using `:auto` You can mount the folder by using the command `mount_9p hostshare` when you are in side the guest
Author
Owner

@omarahm3 commented on GitHub (Aug 27, 2021):

@sickcodes Is there anyway or any lead on how to enable a shared clipboard between host and guest as well?

@omarahm3 commented on GitHub (Aug 27, 2021): @sickcodes Is there anyway or any lead on how to enable a shared clipboard between host and guest as well?
Author
Owner

@sickcodes commented on GitHub (Aug 28, 2021):

@sickcodes Is there anyway or any lead on how to enable a shared clipboard between host and guest as well?

Clipboard wont work because the guest doesn't have access to your clipbaord but if you use the VNC method you can get better latency for typing or autotyping with xdotool

@sickcodes commented on GitHub (Aug 28, 2021): > @sickcodes Is there anyway or any lead on how to enable a shared clipboard between host and guest as well? Clipboard wont work because the guest doesn't have access to your clipbaord but if you use the VNC method you can get better latency for typing or autotyping with xdotool
Author
Owner

@sickcodes commented on GitHub (Aug 28, 2021):

Fixed folder host sharing in 31c95fd640

@sickcodes commented on GitHub (Aug 28, 2021): Fixed folder host sharing in https://github.com/sickcodes/Docker-OSX/commit/31c95fd640f70c657235f7440eca173500c6c9ae
Author
Owner

@gusbemacbe commented on GitHub (Apr 12, 2024):

Good evening, @sickcodes!

I will become if I want to share the folders, and to increase more CPU and more RAM...

docker run -it \
    --device /dev/kvm \
    -p 50922:10022 \
    -v /tmp/.X11-unix:/tmp/.X11-unix \
    -e "DISPLAY=${DISPLAY:-:0.0}" \
    -e GENERATE_UNIQUE=true \
    -e CPU='Haswell-noTSX' \
    -e CPUID_FLAGS='kvm=on,vendor=GenuineIntel,+invtsc,vmware-cpuid-freq=on' \
    -e MASTER_PLIST_URL='https://raw.githubusercontent.com/sickcodes/osx-serial-generator/master/config-custom-sonoma.plist' \
    sickcodes/docker-osx:sonoma

To

SHARE=/home/bene/

docker run -it \
    --device /dev/kvm \
    -p 50922:10022 \
    -v /tmp/.X11-unix:/tmp/.X11-unix \
    -e "DISPLAY=${DISPLAY:-:0.0}" \
    -v "${PWD}/mac_hdd_ng.img:/home/arch/OSX-KVM/mac_hdd_ng.img" \
    -v "${SHARE}:/mnt/hostshare" \
    -e OSX_COMMANDS="echo alpine | sudo -S mount_9p hostshare && /bin/bash" \
    -e RAM=16g \
    -e EXTRA="-smp 16,sockets=8,cores=2,-virtfs local,path=/mnt/hostshare,mount_tag=hostshare,security_model=passthrough,id=hostshare" \
    -e GENERATE_UNIQUE=true \
    -e CPU='Haswell-noTSX' \
    -e CPUID_FLAGS='kvm=on,vendor=GenuineIntel,+invtsc,vmware-cpuid-freq=on' \
    -e MASTER_PLIST_URL='https://raw.githubusercontent.com/sickcodes/osx-serial-generator/master/config-custom-sonoma.plist' \
    sickcodes/docker-osx:sonoma

Is it correct?

@gusbemacbe commented on GitHub (Apr 12, 2024): Good evening, @sickcodes! I will become if I want to share the folders, and to increase more CPU and more RAM... ```sh docker run -it \ --device /dev/kvm \ -p 50922:10022 \ -v /tmp/.X11-unix:/tmp/.X11-unix \ -e "DISPLAY=${DISPLAY:-:0.0}" \ -e GENERATE_UNIQUE=true \ -e CPU='Haswell-noTSX' \ -e CPUID_FLAGS='kvm=on,vendor=GenuineIntel,+invtsc,vmware-cpuid-freq=on' \ -e MASTER_PLIST_URL='https://raw.githubusercontent.com/sickcodes/osx-serial-generator/master/config-custom-sonoma.plist' \ sickcodes/docker-osx:sonoma ``` To ```sh SHARE=/home/bene/ docker run -it \ --device /dev/kvm \ -p 50922:10022 \ -v /tmp/.X11-unix:/tmp/.X11-unix \ -e "DISPLAY=${DISPLAY:-:0.0}" \ -v "${PWD}/mac_hdd_ng.img:/home/arch/OSX-KVM/mac_hdd_ng.img" \ -v "${SHARE}:/mnt/hostshare" \ -e OSX_COMMANDS="echo alpine | sudo -S mount_9p hostshare && /bin/bash" \ -e RAM=16g \ -e EXTRA="-smp 16,sockets=8,cores=2,-virtfs local,path=/mnt/hostshare,mount_tag=hostshare,security_model=passthrough,id=hostshare" \ -e GENERATE_UNIQUE=true \ -e CPU='Haswell-noTSX' \ -e CPUID_FLAGS='kvm=on,vendor=GenuineIntel,+invtsc,vmware-cpuid-freq=on' \ -e MASTER_PLIST_URL='https://raw.githubusercontent.com/sickcodes/osx-serial-generator/master/config-custom-sonoma.plist' \ sickcodes/docker-osx:sonoma ``` Is it correct?
Author
Owner

@gusbemacbe commented on GitHub (Apr 13, 2024):

@sickcodes, it almost worked, but I am unable to share or to use scp.

@gusbemacbe commented on GitHub (Apr 13, 2024): @sickcodes, it almost worked, but I am unable to share or to use `scp`.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/Docker-OSX#166