5

I am trying to containerize a QT-based GUI application (specifically, ITK-SNAP) with X11 forwarding. When I build an image (let's call it itk-snap:3.8) with the following Dockerfile

# 16.04 because https://askubuntu.com/a/895903
FROM ubuntu:16.04
WORKDIR /opt
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y curl libcurl3 libgl1-mesa-dev libsm6 libice6 libxext6 libxrender1 libdbus-1-3 libvips-dev xorg libx11-dev libglu1-mesa-dev libfreetype6-dev freeglut3 freeglut3-dev mesa-common-dev libglew1.5-dev libglm-dev mesa-utils libgl1-mesa-glx libgl1-mesa-dri xserver-xorg-core && \
    curl -LO https://sourceforge.net/projects/itk-snap/files/itk-snap/3.8.0/itksnap-3.8.0-20190612-Linux-x86_64.tar.gz && \
    tar -xvzf itksnap-3.8.0-20190612-Linux-x86_64.tar.gz && \
    rm -rf itksnap-3.8.0-20190612-Linux-x86_64.tar.gz
ENV PATH=$PATH:/opt/itksnap-3.8.0-20190612-Linux-gcc64/bin
CMD itksnap

I can run it with

# `xhost +` to allow any X conn, get display IP with `ifconfig en0 | grep 'inet '`
docker run --rm -ti -e QT_X11_NO_MITSHM="1" -e DISPLAY="192.168.0.148:0" -e LIBGL_DEBUG="verbose" \
    -v /Users/tim/repos/Neurohacking_data:/data:ro \
    -v /tmp/.X11-unix:/tmp/.X11-unix:rw \
    itk-snap:3.8 bash

(the Neurohacking_data bind mount is test data for ITK-SNAP, downloadable here). From the containers shell I can start simple applications like xclock to prove the X11 forwarding is minimally working. Launching itksnap works initially, but when I select an image to load (from the Neurohacking_data), the application hangs and prints the following errors to my console (which does not happen when I load these same images using the native/non-containerized version of ITK-SNAP)

root@a2ee1137fb19:/opt# itksnap
libGL: OpenDriver: trying /usr/lib/x86_64-linux-gnu/dri/tls/swrast_dri.so
libGL: OpenDriver: trying /usr/lib/x86_64-linux-gnu/dri/swrast_dri.so
libGL: Can't open configuration file /root/.drirc: No such file or directory.
libGL: Can't open configuration file /root/.drirc: No such file or directory.
libGL error: No matching fbConfigs or visuals found
libGL error: failed to load driver: swrast
function is no-op
Unrecognized OpenGL version
Unrecognized OpenGL version
function is no-op
Unrecognized OpenGL version
Unrecognized OpenGL version
QOpenGLWidget: Failed to make context current
function is no-op
Unrecognized OpenGL version
Unrecognized OpenGL version
QOpenGLWidget: Failed to make context current
function is no-op
Unrecognized OpenGL version
Unrecognized OpenGL version
QOpenGLWidget: Failed to make context current
function is no-op
Unrecognized OpenGL version
Unrecognized OpenGL version
QOpenGLWidget: Failed to make context current
function is no-op
Unrecognized OpenGL version
Unrecognized OpenGL version
QOpenGLWidget: Failed to make context current
function is no-op
Unrecognized OpenGL version
Unrecognized OpenGL version
QOpenGLWidget: Failed to make context current
function is no-op
Unrecognized OpenGL version
Unrecognized OpenGL version
QOpenGLWidget: Failed to make context current
function is no-op
Unrecognized OpenGL version
Unrecognized OpenGL version
QOpenGLWidget: Failed to make context current
composeAndFlush: makeCurrent() failed
composeAndFlush: makeCurrent() failed
composeAndFlush: makeCurrent() failed
composeAndFlush: makeCurrent() failed
composeAndFlush: makeCurrent() failed

Running glxinfo (with LIBGL_DEBUG=verbose) prints additional debug output. As explained here, errors relating to swrast_dri.so typically mean "that the DRI drivers are not installed correctly".

root@a2ee1137fb19:/opt# glxinfo
name of display: 192.168.0.148:0
libGL: OpenDriver: trying /usr/lib/x86_64-linux-gnu/dri/tls/swrast_dri.so
libGL: OpenDriver: trying /usr/lib/x86_64-linux-gnu/dri/swrast_dri.so
libGL: Can't open configuration file /root/.drirc: No such file or directory.
libGL: Can't open configuration file /root/.drirc: No such file or directory.
libGL error: No matching fbConfigs or visuals found
libGL error: failed to load driver: swrast
X Error of failed request:  GLXBadContext
  Major opcode of failed request:  149 (GLX)
  Minor opcode of failed request:  6 (X_GLXIsDirect)
  Serial number of failed request:  23
  Current serial number in output stream:  22

But there is no explanation how to correctly install the drivers. Did I incorrectly install something, or is the source of my problem actually something else?

Tim
  • 2,123
  • 4
  • 27
  • 44
  • Strictly speaking you've to bind-mount all the graphics subsystem `.so`s from the host system into your container. While Linux' DRI API is pretty much binary compatible between drivers, there still might be small discrepancies between the X server side DRI modules and what's in the container. And Nvidia doesn't use DRI at all and requires the kernel module, the Xorg server module and the libGL to match with each other. – datenwolf Jun 01 '20 at 18:12
  • @datenwolf is there any way to turn off hardware acceleration so you don't have to be coupled to the hosts graphics card? – Tim Jun 02 '20 at 04:28
  • Install Mesa inside the container, then. – datenwolf Jun 02 '20 at 10:34

0 Answers0