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
46.2k stars 2.47k forks source link

Running in Fedora 39 with podman #733

Open petasis opened 9 months ago

petasis commented 9 months ago

OS related issued, please help us identify the issue by posting the output of this

Linux fedser-aero 6.6.8-200.fc39.x86_64 #1 SMP PREEMPT_DYNAMIC

In order to get it run under fedora 39, I had to add this additional option: --security-opt label=type:container_runtime_t.

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 MASTER_PLIST_URL='https://raw.githubusercontent.com/sickcodes/osx-serial-generator/master/config-custom.plist' \
    --security-opt label=type:container_runtime_t \
    sickcodes/docker-osx:monterey
alexjfinch commented 8 months ago

I couldn't quite get your code to work above however, the following managed to work for me in Fedora 39 Gnome Wayland and Nobara 39 KDE Wayland.

The following command is necessary after every reboot;

sudo chmod 777 $XDG_RUNTIME_DIR/wayland-*

Then the following working for me

podman run -it \
    --device /dev/kvm --device /dev/snd \
    -p 50922:10022 \
    -v $XDG_RUNTIME_DIR/$WAYLAND_DISPLAY:/tmp/$WAYLAND_DISPLAY \
    -e WAYLAND_DISPLAY="${WAYLAND_DISPLAY:-wayland-0}" -e DISPLAY=":1" \
    -e GENERATE_UNIQUE=true -e QT_QPA_PLATFORM=wayland \
    -e XDG_RUNTIME_DIR=/tmp -e GDK_BACKEND=wayland \
    -e CLUTTER_BACKEND=wayland \
    -e MASTER_PLIST_URL='https://raw.githubusercontent.com/sickcodes/osx-serial-generator/master/config-custom.plist' \
    --security-opt label=type:container_runtime_t \
    sickcodes/docker-osx:monterey

This worked for me after multiple attempts at trying to solve this.

alexjfinch commented 8 months ago

Further more the QEMU instance stops grabbing inputs after the instance starts running, usually after a couple of apps have opened. The machine hasn't crashed and continues to run as I can see the cursor blinking and iMessage updates, but for some reason the container no longer receives an input

I think its a ram related issue but yet to figure it out

UPDATE Managed to keep the machine running for 15 minutes now by only opening 1 app and assigning 5G of RAM - baremetal has 16GB RAM and I've closed as much as possible to free up RAM for allocation. I've also purged cache using the following shortly after the container span up;

sudo tee /proc/sys/vm/drop_caches <<< 3

Crilum commented 7 months ago

@alexjfinch

Thanks for this!! It works for me too. Solved some frustration :joy:

alexjfinch commented 7 months ago

Further update, managed to get Ventura working with the following;

podman run -it \
    --device /dev/kvm --device /dev/snd \
    -p 50922:10022 \
    -v $XDG_RUNTIME_DIR/$WAYLAND_DISPLAY:/tmp/$WAYLAND_DISPLAY \
    -e WAYLAND_DISPLAY="${WAYLAND_DISPLAY:-wayland-0}" -e DISPLAY=":1" \
    -e GENERATE_UNIQUE=true -e QT_QPA_PLATFORM=wayland \
    -e XDG_RUNTIME_DIR=/tmp -e GDK_BACKEND=wayland \
    -e CLUTTER_BACKEND=wayland \
    -e RAM=5 \
    -e CPU_STRING=6 \
    -e MASTER_PLIST_URL='https://raw.githubusercontent.com/sickcodes/osx-serial-generator/master/config-custom.plist' \
    --security-opt label=type:container_runtime_t \
    sickcodes/docker-osx:ventura
Crilum commented 7 months ago

Yeah, I tried that too, and it does work!

jelabarre59 commented 6 months ago

Your suggested command above didn't work for me. Now I don't know if it's because my user has to be a mamber of some particular group for guestfish, or because I'm nit running Wayland (no support for Wayland in Cinnamon currently).

/var/tmp/opencore-image-ng.sh-102/EFI/OC/Tools
/var/tmp/opencore-image-ng.sh-102/EFI/OC/Tools/ResetSystem.efi
/var/tmp/opencore-image-ng.sh-102/EFI/OC/Tools/Shell.efi
libguestfs: trace: set_verbose true
libguestfs: trace: set_verbose = 0
libguestfs: trace: set_backend "direct"
libguestfs: trace: set_backend = 0
libguestfs: create: flags = 0, handle = 0x55a61fe1a2a0, program = guestfish
guestfish: /tmp/.guestfish-1000: Permission denied
libguestfs: trace: close
libguestfs: closing guestfs handle 0x55a61fe1a2a0 (state 0)
ERROR: starting guestfish failed
### cleaning up ...

This is with Fedora 39, podman version 4.9.3, guestfish 1.52, and the wayland libraries

libwayland-client-1.22.0-2.fc39.x86_64 libwayland-server-1.22.0-2.fc39.x86_64 libwayland-egl-1.22.0-2.fc39.x86_64 libwayland-cursor-1.22.0-2.fc39.x86_64 xisxwayland-2-3.fc39.x86_64 libwayland-client-1.22.0-2.fc39.i686 libwayland-cursor-1.22.0-2.fc39.i686 libwayland-server-1.22.0-2.fc39.i686 libwayland-egl-1.22.0-2.fc39.i686 qt6-qtwayland-6.6.0-1.fc39.x86_64 wayland-devel-1.22.0-2.fc39.x86_64 qt5-qtwayland-5.15.12-2.fc39.x86_64 xorg-x11-server-Xwayland-23.2.4-1.fc39.x86_64 kf5-kwayland-5.113.0-2.fc39.x86_64 qt5-qtwayland-5.15.12-2.fc39.i686

Crilum commented 6 months ago

@jelabarre59 it looks like maybe your /tmp/ permissions are messed up?? Guestfish can't access its tmp file/directory

sickcodes commented 5 months ago

Further update, managed to get Ventura working with the following;

podman run -it \
    --device /dev/kvm --device /dev/snd \
    -p 50922:10022 \
    -v $XDG_RUNTIME_DIR/$WAYLAND_DISPLAY:/tmp/$WAYLAND_DISPLAY \
    -e WAYLAND_DISPLAY="${WAYLAND_DISPLAY:-wayland-0}" -e DISPLAY=":1" \
    -e GENERATE_UNIQUE=true -e QT_QPA_PLATFORM=wayland \
    -e XDG_RUNTIME_DIR=/tmp -e GDK_BACKEND=wayland \
    -e CLUTTER_BACKEND=wayland \
    -e RAM=5 \
    -e CPU_STRING=6 \
    -e MASTER_PLIST_URL='https://raw.githubusercontent.com/sickcodes/osx-serial-generator/master/config-custom.plist' \
    --security-opt label=type:container_runtime_t \
    sickcodes/docker-osx:ventura

This is great for potential wayland/X issues, do you to add a note to the README?

alexjfinch commented 5 months ago

Further update, managed to get Ventura working with the following;

podman run -it \
    --device /dev/kvm --device /dev/snd \
    -p 50922:10022 \
    -v $XDG_RUNTIME_DIR/$WAYLAND_DISPLAY:/tmp/$WAYLAND_DISPLAY \
    -e WAYLAND_DISPLAY="${WAYLAND_DISPLAY:-wayland-0}" -e DISPLAY=":1" \
    -e GENERATE_UNIQUE=true -e QT_QPA_PLATFORM=wayland \
    -e XDG_RUNTIME_DIR=/tmp -e GDK_BACKEND=wayland \
    -e CLUTTER_BACKEND=wayland \
    -e RAM=5 \
    -e CPU_STRING=6 \
    -e MASTER_PLIST_URL='https://raw.githubusercontent.com/sickcodes/osx-serial-generator/master/config-custom.plist' \
    --security-opt label=type:container_runtime_t \
    sickcodes/docker-osx:ventura

This is great for potential wayland/X issues, do you to add a note to the README?

Apologies I've never used github to contribute other than comments! I wouldn't have a clue on how to contribute to the README.

jelabarre59 commented 5 months ago

@jelabarre59 it looks like maybe your /tmp/ permissions are messed up?? Guestfish can't access its tmp file/directory

It's the same as any of my other Fedora systems:

~/src/Docker-OSX$ ls -ld /tmp
drwxrwxrwt. 25 root root 600 Apr  8 20:17 /tmp
alexjfinch commented 5 months ago

@jelabarre59 it looks like maybe your /tmp/ permissions are messed up?? Guestfish can't access its tmp file/directory

It's the same as any of my other Fedora systems:

~/src/Docker-OSX$ ls -ld /tmp
drwxrwxrwt. 25 root root 600 Apr  8 20:17 /tmp

What spin of Fedora are you using? I'll spin up a VM and see if I can replicate your issue.

jelabarre59 commented 5 months ago

Fedora 39 Cinnamon

alexjfinch commented 5 months ago

Fedora 39 Cinnamon

Ok, I think I've managed to get something working for you. You don't need the wayland libraries and, as you state, the Cinnamon spin is still on X11.

You'll need to install a couple of packages;

sudo dnf install xev xprop -y

Once they're installed run, this has be done every time - it doesn't appear to be persistent

xhost +

I've had varying success, but you shouldn't need to disable SELinux, however if you do;

sudo setenforce 0

make sure libvirt and qemu-kvm are installed;

sudo dnf install libvirt qemu-kvm -y

and that you're added to those user groups;

sudo usermod -aG libvirt "${USER}" sudo usermod -aG kvm "${USER}"

That's pretty much all I had to do from a completely fresh install of Fedora cinnamon with the following container;

podman run -it --device /dev/kvm --device /dev/snd -p 50922:10022 -v /tmp/.X11-unix:/tmp/.X11-unix -e "DISPLAY=${DISPLAY:-:0.0}" -e GENERATE_UNIQUE=true -e MASTER_PLIST_URL='https://raw.githubusercontent.com/sickcodes/osx-serial-generator/master/config-custom.plist' --security-opt label=type:container_runtime_t sickcodes/docker-osx:sonoma