jlesage / docker-baseimage-gui

A minimal docker baseimage to ease creation of X graphical application containers
MIT License
1.2k stars 179 forks source link

QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled #141

Open cololi opened 3 months ago

cololi commented 3 months ago

Hey guys, I want build a Qt aplication with current project, and here is my Dockerfile and startup.sh file. The question is app can't startup, it loop return error QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled. I have no idea for solve this problem, what should I do next?

FROM jlesage/baseimage-gui:ubuntu-22.04-v4.6.3
RUN add-pkg xterm
RUN apt update
RUN apt-get install -y apt-utils libxcb-xinerama0 libxcb-xinerama0-dev '^libxcb.*-dev' \
libx11-xcb-dev libglu1-mesa-dev libxrender-dev libxi-dev libxkbcommon-dev libxkbcommon-x11-dev \
libglib2.0-0 libpulse0 libpulse-mainloop-glib0 libnss3 libxcomposite-dev libxdamage1 \
libxrandr2 libxcursor1 libxtst6 libasound2
RUN apt install -y libgl1-mesa-dev

ENV WEB_AUDIO=1
# Slicer
COPY ./Slicer-5.6.2-linux-amd64.tar.gz /tmp/
RUN mkdir -p /opt/slicer
RUN tar -xvf /tmp/Slicer-5.6.2-linux-amd64.tar.gz -C /tmp
RUN mv /tmp/Slicer-5.6.2-linux-amd64/* /opt/slicer
RUN chmod -R a+w /opt/slicer

COPY startapp.sh /startapp.sh
RUN set-cont-env APP_NAME "Slicer"

startapp.sh

/opt/slicer/Slicer

Output logs

> docker run --gpus all --rm -p 5800:5800 -p 5900:5900  slicer
[init        ] container is starting...
[cont-env    ] loading container environment variables...
[cont-env    ] APP_NAME: loading...
[cont-env    ] DISPLAY: executing...
[cont-env    ] DISPLAY: terminated successfully.
[cont-env    ] DISPLAY: loading...
[cont-env    ] DOCKER_IMAGE_PLATFORM: loading...
[cont-env    ] EGL_LOG_LEVEL: executing...
[cont-env    ] EGL_LOG_LEVEL: terminated successfully.
[cont-env    ] EGL_LOG_LEVEL: loading...
[cont-env    ] GSK_RENDERER: executing...
[cont-env    ] GSK_RENDERER: terminated successfully.
[cont-env    ] GSK_RENDERER: loading...
[cont-env    ] GTK2_RC_FILES: executing...
[cont-env    ] GTK2_RC_FILES: terminated successfully.
[cont-env    ] GTK2_RC_FILES: not setting variable.
[cont-env    ] GTK_THEME: executing...
[cont-env    ] GTK_THEME: terminated successfully.
[cont-env    ] GTK_THEME: not setting variable.
[cont-env    ] HOME: loading...
[cont-env    ] LIBGL_DRIVERS_PATH: executing...
[cont-env    ] LIBGL_DRIVERS_PATH: terminated successfully.
[cont-env    ] LIBGL_DRIVERS_PATH: loading...
[cont-env    ] PULSE_CONFIG_PATH: executing...
[cont-env    ] PULSE_CONFIG_PATH: terminated successfully.
[cont-env    ] PULSE_CONFIG_PATH: loading...
[cont-env    ] PULSE_COOKIE: executing...
[cont-env    ] PULSE_COOKIE: terminated successfully.
[cont-env    ] PULSE_COOKIE: loading...
[cont-env    ] PULSE_SERVER: executing...
[cont-env    ] PULSE_SERVER: terminated successfully.
[cont-env    ] PULSE_SERVER: loading...
[cont-env    ] QT_STYLE_OVERRIDE: executing...
[cont-env    ] QT_STYLE_OVERRIDE: terminated successfully.
[cont-env    ] QT_STYLE_OVERRIDE: not setting variable.
[cont-env    ] TAKE_CONFIG_OWNERSHIP: loading...
[cont-env    ] XDG_CACHE_HOME: loading...
[cont-env    ] XDG_CONFIG_HOME: loading...
[cont-env    ] XDG_DATA_HOME: loading...
[cont-env    ] XDG_RUNTIME_DIR: loading...
[cont-env    ] XDG_STATE_HOME: loading...
[cont-env    ] container environment variables initialized.
[cont-secrets] loading container secrets...
[cont-secrets] container secrets loaded.
[cont-init   ] executing container initialization scripts...
[cont-init   ] 10-certs.sh: executing...
[cont-init   ] 10-certs.sh: terminated successfully.
[cont-init   ] 10-check-app-niceness.sh: executing...
[cont-init   ] 10-check-app-niceness.sh: terminated successfully.
[cont-init   ] 10-clean-logmonitor-states.sh: executing...
[cont-init   ] 10-clean-logmonitor-states.sh: terminated successfully.
[cont-init   ] 10-clean-tmp-dir.sh: executing...
[cont-init   ] 10-clean-tmp-dir.sh: terminated successfully.
[cont-init   ] 10-fontconfig-cache-dir.sh: executing...
[cont-init   ] 10-fontconfig-cache-dir.sh: terminated successfully.
[cont-init   ] 10-init-users.sh: executing...
[cont-init   ] 10-init-users.sh: terminated successfully.
[cont-init   ] 10-nginx.sh: executing...
[cont-init   ] 10-nginx.sh: terminated successfully.
[cont-init   ] 10-openbox.sh: executing...
[cont-init   ] 10-openbox.sh: terminated successfully.
[cont-init   ] 10-pkgs-mirror.sh: executing...
[cont-init   ] 10-pkgs-mirror.sh: terminated successfully.
[cont-init   ] 10-pulse.sh: executing...
[cont-init   ] 10-pulse.sh: terminated successfully.
[cont-init   ] 10-set-tmp-dir-perms.sh: executing...
[cont-init   ] 10-set-tmp-dir-perms.sh: terminated successfully.
[cont-init   ] 10-vnc-password.sh: executing...
[cont-init   ] 10-vnc-password.sh: terminated successfully.
[cont-init   ] 10-web-data.sh: executing...
[cont-init   ] 10-web-data.sh: terminated successfully.
[cont-init   ] 10-webauth.sh: executing...
[cont-init   ] 10-webauth.sh: terminated successfully.
[cont-init   ] 10-x11-unix.sh: executing...
[cont-init   ] 10-x11-unix.sh: terminated successfully.
[cont-init   ] 10-xdg-runtime-dir.sh: executing...
[cont-init   ] 10-xdg-runtime-dir.sh: terminated successfully.
[cont-init   ] 15-cjk-font.sh: executing...
[cont-init   ] 15-cjk-font.sh: terminated successfully.
[cont-init   ] 15-install-pkgs.sh: executing...
[cont-init   ] 15-install-pkgs.sh: terminated successfully.
[cont-init   ] 85-take-config-ownership.sh: executing...
[cont-init   ] 85-take-config-ownership.sh: terminated successfully.
[cont-init   ] 89-info.sh: executing...
    ╭――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――╮
    │                                                                      │
    │ Application:           Slicer                                        │
    │ Application Version:   n/a                                           │
    │ Docker Image Version:  n/a                                           │
    │ Docker Image Platform: linux/amd64                                   │
    │                                                                      │
    ╰――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――╯
[cont-init   ] 89-info.sh: terminated successfully.
[cont-init   ] all container initialization scripts executed.
[init        ] giving control to process supervisor.
[supervisor  ] loading services...
[supervisor  ] loading service 'default'...
[supervisor  ] loading service 'app'...
[supervisor  ] loading service 'gui'...
[supervisor  ] loading service 'pulseaudio'...
[supervisor  ] loading service 'xcompmgr'...
[supervisor  ] loading service 'openbox'...
[supervisor  ] loading service 'xvnc'...
[supervisor  ] loading service 'certsmonitor'...
[supervisor  ] service 'certsmonitor' is disabled.
[supervisor  ] loading service 'nginx'...
[supervisor  ] loading service 'webauth'...
[supervisor  ] service 'webauth' is disabled.
[supervisor  ] loading service 'audiorecorder'...
[supervisor  ] loading service 'logmonitor'...
[supervisor  ] service 'logmonitor' is disabled.
[supervisor  ] loading service 'logrotate'...
[supervisor  ] all services loaded.
[supervisor   ] starting services...
[supervisor   ] starting service 'pulseaudio'...
[supervisor   ] starting service 'xvnc'...
[xvnc         ] Xvnc TigerVNC 1.13.1 - built Jun 29 2024 14:24:00
[xvnc         ] Copyright (C) 1999-2022 TigerVNC Team and many others (see README.rst)
[xvnc         ] See https://www.tigervnc.org for information on TigerVNC.
[xvnc         ] Underlying X server release 12014000
[xvnc         ] Wed Aug  7 05:49:29 2024
[xvnc         ]  vncext:      VNC extension running!
[xvnc         ]  vncext:      Listening for VNC connections on /tmp/vnc.sock (mode 0660)
[xvnc         ]  vncext:      Listening for VNC connections on all interface(s), port 5900
[xvnc         ]  vncext:      created VNC server for screen 0
[supervisor   ] starting service 'openbox'...
[supervisor   ] starting service 'xcompmgr'...
[supervisor   ] starting service 'nginx'...
[nginx        ] Listening for HTTP connections on port 5800.
[supervisor   ] starting service 'audiorecorder'...
[audiorecorder] server ready, waiting connections
[audiorecorder] PulseAudio server connection established
[supervisor   ] starting service 'app'...
[app          ] QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled
[app          ] composeAndFlush: makeCurrent() failed
[app          ] QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled
[app          ] composeAndFlush: makeCurrent() failed
[app          ] QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled
[app          ] composeAndFlush: makeCurrent() failed
[app          ] QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled
[app          ] composeAndFlush: makeCurrent() failed
[app          ] QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled
[app          ] composeAndFlush: makeCurrent() failed
[app          ] QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled
[app          ] composeAndFlush: makeCurrent() failed
jlesage commented 3 months ago

Do you have the same issue if you use jlesage/baseimage-gui:ubuntu-22.04-v4.5.3 ?

cololi commented 3 months ago

Do you have the same issue if you use jlesage/baseimage-gui:ubuntu-22.04-v4.5.3 ?

Yes, I have try to rebuild with jlesage/baseimage-gui:ubuntu-22.04-v4.5.3 , the problem is still exists.

ems316 commented 3 months ago

I've also been trying to get this to work for the past week. I've focused on trying to get glxgears to run since this is distributed with the mesa-utils package. I get the following error when running from this container:

"Error: couldn't get an RGB, Double-buffered visual"

I've also attempted to bring in nvidia's docker image nvidia/opengl:1.2-glvnd-runtime-ubuntu22.04 and merge it with this one to get something functional with the gpu. That also does not work. I think it has something to do with X11 and not having a virtual display. I've looked at some examples of virtualgl, but I'm not too familiar with those approaches.

cololi commented 3 months ago

I've also been trying to get this to work for the past week. I've focused on trying to get glxgears to run since this is distributed with the mesa-utils package. I get the following error when running from this container:

"Error: couldn't get an RGB, Double-buffered visual"

I've also attempted to bring in nvidia's docker image nvidia/opengl:1.2-glvnd-runtime-ubuntu22.04 and merge it with this one to get something functional with the gpu. That also does not work. I think it has something to do with X11 and not having a virtual display. I've looked at some examples of virtualgl, but I'm not too familiar with those approaches.

You can try this image accetto/ubuntu-vnc-xfce-opengl-g3, and take my Dockerfile, It works for 3D Slicer.

I've also attempted to bring in nvidia's docker image nvidia/opengl:1.2-glvnd-runtime-ubuntu22.04 and merge it with this one to get something functional with the gpu.

Maybe you should check your docker configure contain the NVIDIA docker runtime or run container argument with --gpus all

ems316 commented 3 months ago

Maybe you should check your docker configure contain the NVIDIA docker runtime or run container argument with --gpus all

I've already been using --runtime=nvidia and that works with jlesage/baseimage-gui:ubuntu-22.04-v4. The issue is more so the opengl support. I can't seem to get that functional in this image regardless of nvidia gpu support. I was just attempting to see if its related to the stock opengl libraries that ship in the base image or if it was something related to X11. I believe it's the latter since nvidia/opengl:1.2-glvnd-runtime-ubuntu22.04 doesn't work with jlesage/baseimage-gui:ubuntu-22.04-v4, even though --runtime=nvidia is functional in the image. I've tested that it is functional by using nvidia-smi in the image. Other approaches for enabling opengl support pass around the X11 socket to enable X11 forwarding --volume /tmp/.X11-unix:/tmp/.X11-unix, however, that seems to go against jlesage's approach of building a virtual desktop and enabling novnc support. I prefer jlesage's approach because it doesn't require you to pass around your X11 socket.

You can try this image accetto/ubuntu-vnc-xfce-opengl-g3, and take my Dockerfile, It works for 3D Slicer.

I use jlesage/baseimage-gui:ubuntu-22.04-v4 image as a base for a lot of images, but I can see if I can get opengl functional with that other image too. I'd like to get opengl support functional in this container image.

pesian commented 2 months ago

This is because the base image uses XVNC, which doesn't support Virtual OpenGL. You need to switch to X11VNC for it to work, as the base Docker image won't help with this.

jlesage commented 2 months ago

This baseimage uses TigerVNC and does support OpenGL/3D extension. However, this has not been enabled yet because it's much harder to compile a static binary with this. This is something I'm working on.

Fazendaaa commented 3 weeks ago

Do you have the same issue if you use jlesage/baseimage-gui:ubuntu-22.04-v4.5.3 ?

This helped me a lot, I was using the Debian release and only changing it to this release fixed my "Could not create surfaceless EGL display: EGL_NOT_INITIALIZED." issue.

Thank you