在容器中运行 openGL 时出现问题

Tim*_*Tim 5 x11 opengl glx itk docker

我正在尝试使用 X11 转发来容器化基于 QT 的 GUI 应用程序(特别是ITK-SNAP)。itk-snap:3.8当我使用以下 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
Run Code Online (Sandbox Code Playgroud)

我可以运行它

# `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
Run Code Online (Sandbox Code Playgroud)

(Neurohacking_data 绑定安装是 ITK-SNAP 的测试数据,可在此处下载)。从容器 shell 中,我可以启动简单的应用程序,例如xclock证明 X11 转发最低限度地工作。启动itksnap最初有效,但是当我选择要加载的图像(从 Neurohacking_data)时,应用程序会挂起并将以下错误打印到我的控制台(当我使用 ITK 的本机/非容器化版本加载这些相同的图像时,不会发生这种情况) -折断)

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
Run Code Online (Sandbox Code Playgroud)

运行glxinfo(使用LIBGL_DEBUG=verbose)打印额外的调试输出。如此处所述,与 相关的错误swrast_dri.so通常意味着“DRI 驱动程序未正确安装”。

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
Run Code Online (Sandbox Code Playgroud)

但没有说明如何正确安装驱动程序。我是否错误地安装了某些东西,或者问题的根源实际上是其他原因?