Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(SOLVED) [Ubuntu 20] [Headless] 'gtk initialization failed' with specific images (big-sure, monterey etc) but auto works. #517

Closed
BadgerHobbs opened this issue Jul 6, 2022 · 8 comments

Comments

@BadgerHobbs
Copy link

Description

Unable to successfully run any headless image other than 'auto' as they stop on gtk initialization failed error.

System info

NAME="Ubuntu"
PRETTY_NAME="Ubuntu 20.04.4 LTS"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal
Filesystem                         Size  Used Avail Use% Mounted on
/dev/mapper/ubuntu--vg-ubuntu--lv  221G  143G   69G  68% /
QEMU emulator version 4.2.1 (Debian 1:4.2-3ubuntu6.23)
Copyright (c) 2003-2019 Fabrice Bellard and the QEMU Project developers
libvirtd (libvirt) 6.0.0
              total        used        free      shared  buff/cache   available
Mem:           15Gi        10Gi       538Mi       2.0Mi       4.7Gi       4.8Gi
Swap:         4.0Gi       1.2Gi       2.8Gi
24
24
crw-rw-rw- 1 root kvm 10, 232 Jul  6 04:36 /dev/kvm
total 8.0K
drwxrwxrwt  2 root root 4.0K Jun 25 05:19 .
drwxrwxrwt 12 root root 4.0K Jul  6 04:44 ..
root        1451  4.0  0.4 5222872 66352 ?       Ssl  02:36   5:14 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
adminis+   96519  0.0  0.0   6432  2548 pts/2    S+   04:44   0:00 grep --color=auto dockerd
kvm:x:108:administrator
docker:x:998:administrator
libvirt:x:118:administrator
libvirt-qemu:x:64055:libvirt-qemu
libvirt-dnsmasq:x:119:

What works

The below command works successfully without issue.

docker run -it \
    --name docker-osx \
    --device /dev/kvm \
    -p 50922:10022 \
    -e TERMS_OF_USE=i_agree \
    -e GENERATE_UNIQUE=true \
    sickcodes/docker-osx:auto

What doesn't work

The below issue returns the gtk initialization failed error, with the below log.

docker run -it \
    --name docker-osx \
    --device /dev/kvm \
    -p 50922:10022 \
    -e TERMS_OF_USE=i_agree \
    -e GENERATE_UNIQUE=true \
    sickcodes/docker-osx:big-sur

Last log lines

QEMU 6.2.0 monitor - type 'help' for more information
(qemu) qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.01H:ECX.xsave [bit 26]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.01H:ECX.avx [bit 28]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.0DH:EAX.xsaveopt [bit 0]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.0DH:EAX [bit 0]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.0DH:EAX [bit 1]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.0DH:EAX [bit 2]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.01H:ECX.xsave [bit 26]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.01H:ECX.avx [bit 28]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.0DH:EAX.xsaveopt [bit 0]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.0DH:EAX [bit 0]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.0DH:EAX [bit 1]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.0DH:EAX [bit 2]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.01H:ECX.xsave [bit 26]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.01H:ECX.avx [bit 28]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.0DH:EAX.xsaveopt [bit 0]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.0DH:EAX [bit 0]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.0DH:EAX [bit 1]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.0DH:EAX [bit 2]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.01H:ECX.xsave [bit 26]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.01H:ECX.avx [bit 28]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.0DH:EAX.xsaveopt [bit 0]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.0DH:EAX [bit 0]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.0DH:EAX [bit 1]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.0DH:EAX [bit 2]
ALSA lib confmisc.c:855:(parse_card) cannot find card '0'
ALSA lib conf.c:5178:(_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:5178:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1334:(snd_func_refer) error evaluating name
ALSA lib conf.c:5178:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5701:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2664:(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:5178:(_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:5178:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1334:(snd_func_refer) error evaluating name
ALSA lib conf.c:5178:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5701:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2664:(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:855:(parse_card) cannot find card '0'
ALSA lib conf.c:5178:(_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:5178:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1334:(snd_func_refer) error evaluating name
ALSA lib conf.c:5178:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5701:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2664:(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:5178:(_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:5178:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1334:(snd_func_refer) error evaluating name
ALSA lib conf.c:5178:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5701:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2664:(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

Comments & previously recommended fixes

Looks like there are a few issues currently mentioning this issue as of time of writing, both on Linux systems and WSL2 from people wanting both headless and displayed deployments:

Recommended fixes from previous issues

# Try install X-11
sudo apt install x11-apps -y

# then test it with:
xeyes
sudo apt install x11-xserver-utils -y
sudo apt install qemu-system-gui

# No permission to access the display
xhost +
# Updating permissions
sudo chmod 666 /dev/kvm
# Running docker as privleged
--privileged
docker run --device /dev/kvm \
    --privileged \
    -p 50922:10022 \
    -e XDG_RUNTIME_DIR=/tmp \
    -e WAYLAND_DISPLAY=$WAYLAND_DISPLAY \
    -e QT_QPA_PLATFORM=wayland \
    -e GDK_BACKEND=wayland \
    -e CLUTTER_BACKEND=wayland \
    -e DISPLAY=:0 \
    -v $XDG_RUNTIME_DIR/$WAYLAND_DISPLAY:/tmp/$WAYLAND_DISPLAY \
    sickcodes/docker-osx:big-sur
-e "DISPLAY=:10
-v /mnt/wslg/.X11-unix:/tmp/.X11-unix \
xhost "+SI:localuser:#1000"

Conclusion

Sadly none of the provided fixes seemed to have worked for me. I guess the question would be what changes between running 'auto' headless compared to 'big-sur' (or any other image)?

@BadgerHobbs
Copy link
Author

Ok, I was able to get it running with the below docker run command and image. The logs should finish on the lines also shown below, then you can ssh into the image with user and alpine to confirm everything is working.

docker run -it \
    --name docker-osx \
    --device /dev/kvm \
    -p 50922:10022 \
    -v "${PWD}/mac_hdd_ng_auto_monterey.img:/image" \
    -e GENERATE_UNIQUE=true \
    -e MASTER_PLIST_URL=https://raw.githubusercontent.com/sickcodes/Docker-OSX/master/custom/config-nopicker-custom.plist \
    -e EXTRA="-display none" \
    sickcodes/docker-osx@sha256:4da5a80bf3aca7306e441a4fad4b92aafcd0fb5f9d0c143dbdf857d162d6903c

Your docker logs should end like this

ALSA lib confmisc.c:855:(parse_card) cannot find card '0'
ALSA lib conf.c:5178:(_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:5178:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1334:(snd_func_refer) error evaluating name
ALSA lib conf.c:5178:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5701:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM default
alsa: Could not initialize ADC
alsa: Failed to open `default':
alsa: Reason: No such file or directory

@BadgerHobbs BadgerHobbs changed the title [Ubuntu 20] [Headless] 'gtk initialization failed' with specific images (big-sure, monterey etc) but auto works. (SOLVED) [Ubuntu 20] [Headless] 'gtk initialization failed' with specific images (big-sure, monterey etc) but auto works. Jul 7, 2022
@sickcodes
Copy link
Owner

Awesome work, apologies for not getting back earlier. I also like the perfectly syntaxed report 😁

@BadgerHobbs
Copy link
Author

Awesome work, apologies for not getting back earlier. I also like the perfectly syntaxed report 😁

Thanks (Can't help myself with the pretty markdown!). Fantastic job with docker-osx as well, glad to be finally getting away from Apple's hardware restrictions. Interesting question will be what will happen when they fully migrate to Arm.

Hopefully this issue helps others, but looks like a PR may be required to resolve whatever changed in the image (Originally commented here #498 (comment))

@ChainsDW
Copy link

I started with these commands and it worked fine. But the container startup is too slow. how can i solve this problem?

@Bharath-Kuppusamy-ZS0197

I followed the initial setup after replicating the issue, I executed these

$ sudo docker run -i --device /dev/kvm -p 50922:10022 -e GENERATE_UNIQUE=true -e DEVICE_MODEL="iMacPro1,1" -e WIDTH=1600 -e HEIGHT=900 -v /tmp/.X11-unix:/tmp/.X11-unix -e "DISPLAY:=0.0" sickcodes/docker-osx:big-sur
$ xhost +
$ docker start -ai -i <container_id>

Worked like a charm!

@yarbshk
Copy link

yarbshk commented Jul 6, 2023

i had the same issue but i managed to fix it by building my own image:

git clone https://github.com/sickcodes/Docker-OSX.git
cd Docker-OSX
docker build -t docker-osx .
xhost +
docker run --device /dev/kvm --device /dev/snd -v /tmp/.X11-unix:/tmp/.X11-unix -e "DISPLAY=${DISPLAY:-:0.0}" docker-osx:latest

it worked for me on Ubuntu 22.04.2 LTS. also i executed commands from "Recommended fixes from previous issues" section above (not sure if any of those was actually needed though).

it is as simple as that. hope it helps somebody.

@AldenIsMe AldenIsMe mentioned this issue Sep 9, 2023
@SimonBard
Copy link

i had the same issue but i managed to fix it by building my own image:

git clone https://github.com/sickcodes/Docker-OSX.git
cd Docker-OSX
docker build -t docker-osx .
xhost +
docker run --device /dev/kvm --device /dev/snd -v /tmp/.X11-unix:/tmp/.X11-unix -e "DISPLAY=${DISPLAY:-:0.0}" docker-osx:latest

it worked for me on Ubuntu 22.04.2 LTS. also i executed commands from "Recommended fixes from previous issues" section above (not sure if any of those was actually needed though).

it is as simple as that. hope it helps somebody.

Many thanks. It did not help me unfortunately.
I am getting:

qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.0DH:EAX [bit 2]
(qemu) gtk initialization failed

My system is a J4202-itx, which supports VT-x

@mcint
Copy link

mcint commented Jun 3, 2024

https://unix.stackexchange.com/questions/710944/qemu-warning-host-doesnt-support-requested-feature-cpuid-80000001hecx-svm-b

If you can modify arguments passed to qemu, adding -cpu host seems to be a simple naive fix for a similar issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants