sickcodes / Docker-OSX

Run macOS VM in a Docker! Run near native OSX-KVM in Docker! X11 Forwarding! CI/CD for OS X Security Research! Docker mac Containers.
https://hub.docker.com/r/sickcodes/docker-osx
GNU General Public License v3.0
36.1k stars 1.78k forks source link

Copy files from Host into container User Folder ? #242

Open mhabsaoui opened 3 years ago

mhabsaoui commented 3 years ago

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...

sickcodes commented 3 years ago

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

omarahm3 commented 2 years ago

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

sickcodes commented 2 years ago

@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 2 years ago

Fixed folder host sharing in https://github.com/sickcodes/Docker-OSX/commit/31c95fd640f70c657235f7440eca173500c6c9ae

gusbemacbe commented 2 months ago

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 2 months ago

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