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?