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.09k stars 2.46k forks source link

gtk initialization failed (Possibly ALSA Related) #791

Open tokenwizard opened 1 month ago

tokenwizard commented 1 month ago

Requested info is logged below. Also, I put the console output that seemed relevant (ALSA errors just before the system exists with the gtk initialization error).

Is ALSA a prerequisite for this to work? Is there something else I'm missing?

I regularly run other docker containers on this system.

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

uname -a \ Linux OfficePC 6.9.9-1-MANJARO #1 SMP PREEMPT_DYNAMIC Fri Jul 12 10:32:52 UTC 2024 x86_64 GNU/Linux

; echo "${DISPLAY}" \ :0.0

; echo 1 | sudo tee /sys/module/kvm/parameters/ignore_msrs \ 1

; grep NAME /etc/os-release \

PRETTY_NAME="Manjaro Linux"

; df -h . \

Filesystem                                             Size  Used Avail Use% Mounted on
/dev/mapper/luks-7378c251-aea2-4404-979a-f22622c3604f  1.8T  440G  1.3T  26% /

; qemu-system-x86_64 --version \

QEMU emulator version 9.0.1
Copyright (c) 2003-2024 Fabrice Bellard and the QEMU Project developers

; libvirtd --version \ libvirtd (libvirt) 10.5.0

; free -mh \

               total        used        free      shared  buff/cache   available
Mem:            62Gi        35Gi       1.3Gi       6.7Gi        33Gi        27Gi
Swap:             0B          0B          0B

; nproc \ 16

; egrep -c '(svm|vmx)' /proc/cpuinfo \

egrep: warning: egrep is obsolescent; using grep -E
16

; ls -lha /dev/kvm \ crw-rw-rw- 1 root kvm 10, 232 Jul 31 11:15 /dev/kvm

; ls -lha /tmp/.X11-unix/ \

total 0
drwxrwxrwt  2 root root  60 Jul 28 12:08 .
drwxrwxrwt 21 root root 720 Jul 31 11:14 ..
srwxrwxrwx  1 root root   0 Jul 28 12:08 X0

; ps aux | grep dockerd \

root         954  0.0  0.1 3366620 82132 ?       Ssl  Jul28   1:45 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
tokenwi+ 1264318  0.0  0.0   6616  4156 pts/2    S+   11:22   0:00 grep --colour=auto dockerd

; docker ps | grep osx \ (NULL)

; grep "docker|kvm|virt" /etc/group

kvm:x:992:libvirt-qemu,qemu
libvirt:x:961:
libvirt-qemu:x:960:
docker:x:954:tokenwizard

Seemingly-relevant log output:

+ exec qemu-system-x86_64 -m 4000 -cpu Haswell-noTSX,kvm=on,vendor=GenuineIntel,+invtsc,vmware-cpuid-freq=on -machine q35,accel=kvm:tcg -smp 4,cores=4 -device qemu-xhci,id=xhci -device usb-kbd,bus=xhci.0 -device usb-tablet,bus=xhci.0 -device 'isa-applesmc,osk=ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc' -drive if=pflash,format=raw,readonly=on,file=/home/arch/OSX-KVM/OVMF_CODE.fd -drive if=pflash,format=raw,file=/home/arch/OSX-KVM/OVMF_VARS-1024x768.fd -smbios type=2 -audiodev alsa,id=hda -device ich9-intel-hda -device hda-duplex,audiodev=hda -device ich9-ahci,id=sata -drive id=OpenCoreBoot,if=none,snapshot=on,format=qcow2,file=/home/arch/OSX-KVM/OpenCore/OpenCore.qcow2 -device ide-hd,bus=sata.2,drive=OpenCoreBoot -device ide-hd,bus=sata.3,drive=InstallMedia -drive id=InstallMedia,if=none,file=/home/arch/OSX-KVM/BaseSystem.img,format=qcow2 -drive id=MacHDD,if=none,file=/home/arch/OSX-KVM/mac_hdd_ng.img,format=qcow2 -device ide-hd,bus=sata.4,drive=MacHDD -netdev user,id=net0,hostfwd=tcp::10022-:22,hostfwd=tcp::5900-:5900, -device vmxnet3,netdev=net0,id=net0,mac=52:54:00:09:49:17 -monitor stdio -boot menu=on -vga vmware
Authorization required, but no authorization protocol specified

QEMU 9.0.0 monitor - type 'help' for more information
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.01H:ECX.pcid [bit 17]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.07H:EBX.erms [bit 9]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.07H:EBX.invpcid [bit 10]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.01H:ECX.pcid [bit 17]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.07H:EBX.erms [bit 9]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.07H:EBX.invpcid [bit 10]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.01H:ECX.pcid [bit 17]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.07H:EBX.erms [bit 9]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.07H:EBX.invpcid [bit 10]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.01H:ECX.pcid [bit 17]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.07H:EBX.erms [bit 9]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.07H:EBX.invpcid [bit 10]
(qemu) ALSA lib confmisc.c:855:(parse_card) cannot find card '0'
ALSA lib conf.c:5204:(_snd_config_evaluate) function snd_func_card_inum returned error: No such file or directory
ALSA lib confmisc.c:422:(snd_func_concat) error evaluating strings
ALSA lib conf.c:5204:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1342:(snd_func_refer) error evaluating name
ALSA lib conf.c:5204:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5727:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2721:(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:855:(parse_card) cannot find card '0'
ALSA lib conf.c:5204:(_snd_config_evaluate) function snd_func_card_inum returned error: No such file or directory
ALSA lib confmisc.c:422:(snd_func_concat) error evaluating strings
ALSA lib conf.c:5204:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1342:(snd_func_refer) error evaluating name
ALSA lib conf.c:5204:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5727:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2721:(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: Could not create a backend for voice `dac'
ALSA lib confmisc.c:855:(parse_card) cannot find card '0'
ALSA lib conf.c:5204:(_snd_config_evaluate) function snd_func_card_inum returned error: No such file or directory
ALSA lib confmisc.c:422:(snd_func_concat) error evaluating strings
ALSA lib conf.c:5204:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1342:(snd_func_refer) error evaluating name
ALSA lib conf.c:5204:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5727:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2721:(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:855:(parse_card) cannot find card '0'
ALSA lib conf.c:5204:(_snd_config_evaluate) function snd_func_card_inum returned error: No such file or directory
ALSA lib confmisc.c:422:(snd_func_concat) error evaluating strings
ALSA lib conf.c:5204:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1342:(snd_func_refer) error evaluating name
ALSA lib conf.c:5204:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5727:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2721:(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: Could not create a backend for voice `adc'
gtk initialization failed
tokenwizard commented 1 month ago

I tried updating my run command to use PulseAudio by adding these lines:

-e AUDIO_DRIVER=pa,server=unix:/tmp/pulseaudio.socket \
-v "/run/user/$(id -u)/pulse/native:/tmp/pulseaudio.socket" \
-e PULSE_SERVER=unix:/tmp/pulseaudio.socket \

and now it no longer shows the ALSA-related errors, but still exits, whether run with sudo or not.

docker-osx-1  | + exec qemu-system-x86_64 -m 4000 -cpu Haswell-noTSX,kvm=on,vendor=GenuineIntel,+invtsc,vmware-cpuid-freq=on -machine q35,accel=kvm:tcg -smp 4,cores=4 -device qemu-xhci,id=xhci -device usb-kbd,bus=xhci.0 -device usb-tablet,bus=xhci.0 -device 'isa-applesmc,osk=ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc' -drive if=pflash,format=raw,readonly=on,file=/home/arch/OSX-KVM/OVMF_CODE.fd -drive if=pflash,format=raw,file=/home/arch/OSX-KVM/OVMF_VARS-1024x768.fd -smbios type=2 -audiodev pa,server=unix:/tmp/pulseaudio.socket,id=hda -device ich9-intel-hda -device hda-duplex,audiodev=hda -device ich9-ahci,id=sata -drive id=OpenCoreBoot,if=none,snapshot=on,format=qcow2,file=/home/arch/OSX-KVM/OpenCore/OpenCore.qcow2 -device ide-hd,bus=sata.2,drive=OpenCoreBoot -device ide-hd,bus=sata.3,drive=InstallMedia -drive id=InstallMedia,if=none,file=/home/arch/OSX-KVM/BaseSystem.img,format=qcow2 -drive id=MacHDD,if=none,file=/home/arch/OSX-KVM/mac_hdd_ng.img,format=qcow2 -device ide-hd,bus=sata.4,drive=MacHDD -netdev user,id=net0,hostfwd=tcp::10022-:22,hostfwd=tcp::5900-:5900, -device vmxnet3,netdev=net0,id=net0,mac=52:54:00:09:49:17 -monitor stdio -boot menu=on -vga vmware
docker-osx-1  | Authorization required, but no authorization protocol specified
docker-osx-1  | 
docker-osx-1  | pulseaudio: pa_context_connect() failed
docker-osx-1  | pulseaudio: Reason: Connection refused
docker-osx-1  | pulseaudio: Failed to initialize PA contextqemu-system-x86_64: could not connect to PulseAudio server
docker-osx-1 exited with code 1
cjdb commented 1 month ago

I was able to get around this by following the steps in https://github.com/sickcodes/Docker-OSX/issues/7#issuecomment-639356240 on my host.

Qianxilihulu commented 1 month ago

ALSA is not related and happens to everyone, according to README. The real error is the last line, "gtk initialization failed," which is most likely about how you set up your display. Please provide your docker command for further troubleshoot. you should also check if you're using wayland or X. There're many issues about X already. i'm using Wayland, and one important thing is /run/user/{UID} has been given enough permission.