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
48.44k stars 2.69k forks source link

Unable to init server. gtk initialization failed #106

Closed rcg12387 closed 3 years ago

rcg12387 commented 4 years ago

Hi. I cannot run this docker image though run with allowing SSH into OSX. os: Ubuntu 18.04.5 LTS (GNU/Linux 5.4.0-52-generic x86_64) RAM: 64GB cpu model name: Intel(R) Xeon(R) CPU E5-2630 v4 @ 2.20GHz count of cpus: 20 remote: using MobaXterm Professional Edition v10.7

$ sudo docker run --device /dev/kvm --device /dev/snd -e RAM=16 -p 50922:10022 -v /tmp/.X11-unix:/tmp/.X11-unix -e "DISPLAY=${DISPLAY:-:0.0}" sickcodes/docker-osx:latest
ssh-keygen: generating new host keys: RSA DSA ECDSA ED25519
Unable to init server: Could not connect: Connection refused
QEMU 5.1.0 monitor - type 'help' for more information
(qemu) ALSA lib pcm_dmix.c:1075:(snd_pcm_dmix_open) unable to open slave
alsa: Could not initialize DAC
alsa: Failed to open `default':
alsa: Reason: No such file or directory
ALSA lib pcm_dmix.c:1075:(snd_pcm_dmix_open) unable to open slave
alsa: Could not initialize DAC
alsa: Failed to open `default':
alsa: Reason: No such file or directory
audio: Failed to create voice `dac'
ALSA lib pcm_dsnoop.c:638:(snd_pcm_dsnoop_open) unable to open slave
alsa: Could not initialize ADC
alsa: Failed to open `default':
alsa: Reason: No such file or directory
ALSA lib pcm_dsnoop.c:638:(snd_pcm_dsnoop_open) unable to open slave
alsa: Could not initialize ADC
alsa: Failed to open `default':
alsa: Reason: No such file or directory
audio: Failed to create voice `adc'
gtk initialization failed
$ echo $DISPLAY
localhost:12.0
$ echo $TERM
xterm
$ pgrep -a X
2763 /usr/bin/Xwayland :1024 -rootless -terminate -accessx -core -listen 4 -listen 5 -displayfd 6
$ egrep -c '(svm|vmx)' /proc/cpuinfo
20
$ sudo dokerd
sudo: dokerd: command not found
$ sudo systemctl enable docker
Synchronizing state of docker.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable docker

Tried this but also failed:

$ sudo apt install x11-xserver-utils
$ xhost +
$ sudo docker run --privileged -e "DISPLAY=${DISPLAY:-:0.0}" -v /tmp/.X11-unix:/tmp/.X11-unix sickcodes/docker-osx ./OpenCore-Boot.sh
Unable to init server: Could not connect: Connection refused
Could not access KVM kernel module: Permission denied
qemu-system-x86_64: failed to initialize kvm: Permission denied

Please help me.

sickcodes commented 4 years ago

Try changing display to :12.0

-e "DISPLAY=12.0"

Remove sudo from docker run and add yourself to the Docker group

sudo chmod 666 /dev/kvm

Remove opencoreboot from the end

Remove --device /dev/snd

BridgetNichols commented 4 years ago

I'm having the exact same issue. Their was an issue posted yesterday that was having the same output too. I've tried everything posted so far and haven't had any luck either.

rcg12387 commented 4 years ago

Try changing display to :12.0

-e "DISPLAY=12.0"

Remove sudo from docker run and add yourself to the Docker group

sudo chmod 666 /dev/kvm

Remove opencoreboot from the end

Remove --device /dev/snd

@sickcodes Thank you for your reply. I have tried your recommendations but also failed.

$ sudo usermod -aG docker "DL-001"
$ sudo chmod 666 /dev/kvm
$ docker run --device /dev/kvm -e RAM=16 -p 50922:10022 -v /tmp/.X11-unix:/tmp/.X11-unix -e "DISPLAY=12.0" sickcodes/docker-osx:latest
docker: unknown server OS: .
See 'docker run --help'.

And tried this according to this.

$ sudo chmod 666 /var/run/docker.sock
$ docker run hello-world
Hello from Docker!
This message shows that your installation appears to be working correctly.
$ docker run --device /dev/kvm -v /tmp/.X11-unix:/tmp/.X11-unix -e "DISPLAY=12.0" sickcodes/docker-osx:latest
ssh-keygen: generating new host keys: RSA DSA ECDSA ED25519
Unable to init server: Could not connect: Connection refused
QEMU 5.1.0 monitor - type 'help' for more information
(qemu) ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5233:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM default
alsa: Could not initialize DAC
alsa: Failed to open `default':
alsa: Reason: No such file or directory
ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5233:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM default
alsa: Could not initialize DAC
alsa: Failed to open `default':
alsa: Reason: No such file or directory
audio: Failed to create voice `dac'
ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5233:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM default
alsa: Could not initialize ADC
alsa: Failed to open `default':
alsa: Reason: No such file or directory
ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5233:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM default
alsa: Could not initialize ADC
alsa: Failed to open `default':
alsa: Reason: No such file or directory
audio: Failed to create voice `adc'
gtk initialization failed
sickcodes commented 4 years ago

I just tested using the code from the readme:

docker run \
    --device /dev/kvm \
    --device /dev/snd \
    -e RAM=4 \
    -p 50922:10022 \
    -v /tmp/.X11-unix:/tmp/.X11-unix \
    -e "DISPLAY=${DISPLAY:-:0.0}" \
    sickcodes/docker-osx:latest 

Screenshot

rcg12387 commented 4 years ago

Thank you for your reply. It still fails. I have tried "How to Install macOS VM on Linux" and it seems working. Awesome.

sickcodes commented 4 years ago

Thank you for your reply. It still fails. I have tried "How to Install macOS VM on Linux" and it seems working. Awesome.

Haha great :P That was the original version!

rcg12387 commented 4 years ago

@sickcodes I have a problem with mouse moving. Two cursors are appeared in the screen (one is of QEMU, another one is of MacOS, I think), and these two are not synchronized. Do you have any suggestion? This issue is not appropriate to this git repo, anyway please help me.

sickcodes commented 4 years ago

One mouse should be for the host the other mouse should be the macs mouse cursor.

Dont zoom in or out as it will change the cursor calibration

I think in the qemu menu there's options to change the way the mouse works. If the mouse dies, change usb-mouse to usb-tablet in the launcher script, was necessary for me.

rcg12387 commented 4 years ago

If the mouse dies, change usb-mouse to usb-tablet in the launcher script, was necessary for me.

I have used OpenCore-Boot.sh, it is written as -usb -device usb-kbd -device usb-tablet. You mean this don't you?