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

Can't run OS X inside of OS X #6

Open tibbon opened 4 years ago

tibbon commented 4 years ago

No host support it seems

docker run --privileged -v /tmp/.X11-unix:/tmp/.X11-unix sickcodes/docker-osx
Unable to init server: Could not connect: Connection refused
Could not access KVM kernel module: No such file or directory
qemu-system-x86_64: failed to initialize kvm: No such file or directory
kongminhao commented 4 years ago

matryoshka forbidden.

suda commented 4 years ago

It probably won't be possible to run it on macOS as Docker for Mac is actually running a tiny Linux VM with Docker inside, so the "matryoshka" would even be deeper.

sickcodes commented 4 years ago

No host support it seems

docker run --privileged -v /tmp/.X11-unix:/tmp/.X11-unix sickcodes/docker-osx
Unable to init server: Could not connect: Connection refused
Could not access KVM kernel module: No such file or directory
qemu-system-x86_64: failed to initialize kvm: No such file or directory

Try this:

echo $DISPLAY

# ARCH
sudo pacman -S xorg-xhost

# UBUNTU DEBIAN
sudo apt install x11-xserver-utils

# CENTOS RHEL FEDORA
sudo yum install xorg-x11-server-utils

# then run
xhost +

docker run --privileged -e "DISPLAY=${DISPLAY:-:0.0}" -v /tmp/.X11-unix:/tmp/.X11-unix sickcodes/docker-osx ./OpenCore-Boot.sh
sickcodes commented 4 years ago

I can put up VNC version if you want, the original I had was VNC before I saw how someone else did the x11 fowarding

romancin commented 4 years ago

I can put up VNC version if you want, the original I had was VNC before I saw how someone else did the x11 fowarding

It would be awesome for running macOS Server on a headless server.

sickcodes commented 4 years ago

Got it ready, will post in about three hours 😎

sickcodes commented 4 years ago

https://github.com/sickcodes/Docker-OSX/tree/master/vnc-version

tibbon commented 4 years ago

Awesome, thank you!!!! I was almost just asking for a joke, but it does seem useful now that I think of it!

sickcodes commented 4 years ago

You’re welcome, just promise to show us a screenshot once you get it running :)!

sickcodes commented 4 years ago

Let us know if it worked guys :)

sickcodes commented 4 years ago

Leaving this open until someone confirms

matryoshka

tibbon commented 4 years ago

Hmm, I'm getting this error now. Perhaps I'm just doing it wrong?

docker build -t local/docker-osx .
Sending build context to Docker daemon   5.12kB
Step 1/16 : FROM sickcodes/docker-osx:latest
 ---> 330edd24b7ee
Step 2/16 : MAINTAINER 'https://sick.codes' <https://sick.codes>
 ---> Using cache
 ---> 1f9a28c49b1a
Step 3/16 : USER arch
 ---> Using cache
 ---> b3064897f87d
Step 4/16 : RUN sudo pacman -S tigervnc xterm xorg-xhost xdotool ufw --noconfirm
 ---> Using cache
 ---> 3a7f37b66d2d
Step 5/16 : RUN mkdir ${HOME}/.vnc
 ---> Using cache
 ---> c089588609b7
Step 6/16 : RUN printf '%s\n' 'xinit &' 'xterm &' > ~/.vnc/xstartup
 ---> Using cache
 ---> 1b2648e8f176
Step 7/16 : RUN printf '%s\n%s\n%s\n\n' 'export DISPLAY=:99' 'vncserver -kill :99 || true' 'vncserver -geometry 1920x1080 -depth ${DEPTH:=24} -xstartup ~/.vnc/xstartup :99' > vnc.sh
 ---> Using cache
 ---> 89deedc7bcb6
Step 8/16 : RUN cat vnc.sh OpenCore-Boot.sh > OpenCore-Boot_custom.sh
 ---> Using cache
 ---> e21a17a07243
Step 9/16 : RUN chmod +x OpenCore-Boot_custom.sh
 ---> Using cache
 ---> b4f13ef4a4c1
Step 10/16 : RUN tee vncpasswd_file <<< "${VNC_PASSWORD:=$(openssl rand -hex 4)}"
 ---> Using cache
 ---> e7b48d1a15ef
Step 11/16 : RUN vncpasswd -f < vncpasswd_file > ${HOME}/.vnc/passwd
 ---> Using cache
 ---> 266c4cc51c58
Step 12/16 : RUN chmod 600 ~/.vnc/passwd
 ---> Using cache
 ---> af74e65141be
Step 13/16 : RUN printf '\n\n\n\n%s\n%s\n\n\n\n' '===========VNC_PASSWORD========== ' "$(<vncpasswd_file)"
 ---> Using cache
 ---> 93b5440515eb
Step 14/16 : WORKDIR /home/arch/OSX-KVM
 ---> Using cache
 ---> 6aca647168a0
Step 15/16 : USER arch
 ---> Using cache
 ---> 1ab163ce8287
Step 16/16 : CMD ./OpenCore-Boot_custom.sh
 ---> Using cache
 ---> fca260b8ecbf
Successfully built fca260b8ecbf
Successfully tagged local/docker-osx:latest
me@mymac vnc-version % docker run --privileged -e "DISPLAY=${DISPLAY:-:0.0}" -v /tmp/.X11-unix:/tmp/.X11-unix local/docker-osx ./OpenCore-Boot.sh
Unable to init server: Could not connect: Connection refused
Could not access KVM kernel module: No such file or directory
qemu-system-x86_64: failed to initialize kvm: No such file or directory

I did a brew install qemu but I don't think that's my issue?

I also tried:

me@mymac vnc-version % docker run local/docker-osx

Can't find file /home/arch/.vnc/24a99c353255:99.pid
You'll have to kill the Xvnc process manually

xauth:  file /home/arch/.Xauthority does not exist

New '24a99c353255:99 (arch)' desktop is 24a99c353255:99

Creating default config /home/arch/.vnc/config
Starting applications specified in /home/arch/.vnc/xstartup
Log file is /home/arch/.vnc/24a99c353255:99.log

Could not access KVM kernel module: No such file or directory
qemu-system-x86_64: failed to initialize kvm: No such file or directory
sickcodes commented 4 years ago

Noted, if anyone has had success with this issue, would be great to hear :) I will try test it later today

cmosetick commented 4 years ago
echo $DISPLAY
/private/tmp/com.apple.launchd.lWN3QYe0Ym/org.macosforge.xquartz:0

I get a similar output on OS X 10.15.5.
docker for mac desktop version 2.3.0.3 docker version 19.03.8

docker run --privileged -e "DISPLAY=${DISPLAY:-:0.0}" -v /tmp/.X11-unix:/tmp/.X11-unix cmosetick/docker-osx:vnc-version
ssh-keygen: generating new host keys: RSA DSA ECDSA ED25519

Can't find file /home/arch/.vnc/3a2312c0264b:99.pid
You'll have to kill the Xvnc process manually

Warning: 3a2312c0264b:99 is taken because of /tmp/.X11-unix/X99
Remove this file if there is no X server 3a2312c0264b:99
A VNC server is already running as :99
Unable to init server: Could not connect: Connection refused
Could not access KVM kernel module: No such file or directory
qemu-system-x86_64: failed to initialize kvm: No such file or directory
sickcodes commented 4 years ago

Try

-e DISPLAY=:0

sickcodes commented 4 years ago

But that’s for the X11 version. Don’t use display for the VNC version. Use the instructions in the top of the Dockerfile for VNC


# Build:
#
#       # write down the password at the end
#       docker build -t docker-osx-vnc .
# 
# Run:
#       
#       docker run -p 8888:5999 -p 50922:10022 -d --privileged docker-osx-vnc:latest
#
#
# Connect locally (safe):
#
#       VNC Host:     localhost:8888
shuangwei-Ye commented 4 years ago

emmmmm..... i want to know the result. i have this same issue.

shuangwei-Ye commented 4 years ago

ARCH

but...are these linux version? ARCH \centos \ UBUNTU. how to use this instruction in Mac os ?

sickcodes commented 4 years ago

ARCH

but...are these linux version? ARCH \centos \ UBUNTU. how to use this instruction in Mac os ?

This is a Dockerfile, so you'd need Docker first: https://docs.docker.com/engine/install/

shuangwei-Ye commented 3 years ago

ARCH

but...are these linux version? ARCH \centos \ UBUNTU. how to use this instruction in Mac os ?

This is a Dockerfile, so you'd need Docker first: https://docs.docker.com/engine/install/

I've already downloaded Docker Desktop for Mac (macOS), then run this project.

now I got the same result as tibbon

Unable to init server: Could not connect: Connection refused
Could not access KVM kernel module: No such file or directory
qemu-system-x86_64: failed to initialize kvm: No such file or directory

I wonder if Mac can run a Docker-OSX~

thanks

drewdrew21b commented 3 years ago

I was able to build using docker-osx:vnc-version and launch with the suggested options in the script (docker run -p 8888:5999 -p 50922:10022 -d --privileged ).

I am seeing the following when logging in via macOS built in Screen Sharing (and Real VNC) using the randomly generated VNC password: Screen Shot 2020-10-01 at 3 09 23 PM

When I try to click on the Recovery Drive to install macOS, I get the following kernel panic: Screen Shot 2020-10-01 at 3 15 08 PM

I am using Portainer (1.24.1) to manage Docker Desktop (2.4.0.0 build 48506) with brew QEMU (5.1.0) on MacOS 10.15.7.

This looks like it's somewhat working, up until the kernel panic's. Is there anything else I can grab to debug this?

sickcodes commented 3 years ago

@drewdrew21b thats pretty close!

I'm not sure, I will try in a Docker-OSX to replicate this tomorrow so we can get the true full circle: OSX in OSX

You can try building the main image And then using that image in the VNC script (change FROM to your build)

drewdrew21b commented 3 years ago

@sickcodes I tried to create a build on my MacBook Pro and Mac Mini and am getting what appears to be the same crash in both instances from macOS recovery when booting the recovery kernel.

majest commented 3 years ago

Any updates on that? The OSX in OSX feature would be really useful.

sickcodes commented 3 years ago

Unfortunately I can't test it

gitpushdashf commented 3 years ago

Same issue for me. Thanks for making this, though! Screen Shot 2020-10-20 at 12 43 26 PM

adamwolf commented 3 years ago

I get the same issue as gitpushdashf. (Is there a common emoji reaction for "this happens to me, too"?)

esnosy commented 3 years ago

MacOSX doesn't have KVM, KVM is Linux only, the project relies on KVM, therefore it can't run on MacOSX

sickcodes commented 3 years ago

You can run without it KVM on any platform.

I did it before, using OSX-KVM on a raspberry Pi.

A few command changes are needed I'll try and find the bash history. I would've saved it.

Also, don't when I did it on a RPI, I never got past the Apple Logo. Maybe because the SD card is exponentially slower than an SSD.

Don't forget the disk is large and needs more a bit of ram.

The Dockerfile is not multiarch. You can tell because we have some x86 patches.

It's 100% possible.

deepio commented 3 years ago

I really wanted to make matryoshka happen, but for now it seems I need to stick with https://github.com/myspaghetti/macos-virtualbox when on a MacOS host and Docker-OSX when on *nix.

This is how I ran it and got as far as the others:

lbdl commented 3 years ago

seems I have the same issue as everyone else, can get the container to start using the same as @deepio has posted however the startup kernel panics in the same manner. Steps install XQuartz -> allow connections from network clients.

xhost +localhost
docker run --privileged -e DISPLAY=host.docker.internal:0 sickcodes/docker-osx
Screenshot 2021-04-27 at 18 36 19
viteinfinite commented 3 years ago

H! Any news on this?

sickcodes commented 2 years ago

Update on this issue: https://github.com/KhaosT/MacVM

sickcodes commented 2 years ago

Huge update:

https://github.com/knazarov/homebrew-qemu-virgl

Maybe we just need accel=hvf 😂

gitpushdashf commented 2 years ago

Wow, very cool!

selam commented 1 year ago

i have same issue