Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

libGL error: failed to load driver swrast in docker container

I have a docker container from which I am trying to run a pyqt app. Everything works well except a chunk of the GUI is not able to render. The docker logs throw this out:

libGL error: failed to load driver: swrast
X Error: GLXBadContext 169
 Extension:    154 (Uknown extension)
 Minor opcode: 6 (Unknown request)
 Resource id:  0x6400003
X Error: BadValue (integer parameter out of range for operation) 2
 Extension:    154 (Uknown extension)
 Minor opcode: 3 (Unknown request)
 Resource id:  0x0
...
QGLContext::makeCurrent(): Failed.

In my Dockerfile, I tried installing pretty much all the packages I could find that might be related, including mesa-utils.

In terms of the docker-compose file, here's what it looks like:

version: '2'
    services:
    gui:
        build: .
        volumes:
        - .:/usr/src
        - /tmp/.X11-unix:/tmp/.X11-unix
        command: /bin/bash -c "python start.py"
        environment:
        - DISPLAY=unix$DISPLAY
        - QT_X11_NO_MITSHM=1
        devices:
        - "/dev/snd:/dev/snd"
        - "/dev/dri:/dev/dri"
        privileged: true

Any ideas what I might be missing?

like image 904
HappyCry Avatar asked May 24 '17 18:05

HappyCry


People also ask

What is LibGL error?

LibGL error: failed to load driver: swrast is an error that usually occurs when trying to use Steam on Ubuntu. It appears to be an issue on the 32bit openGL drivers.


1 Answers

Figured it out. I had to build the gui with hardware accelerated OpenGL support. Theres a repo (https://github.com/gklingler/docker3d) that contains docker images with nvidia or other graphics drivers support.

The other catch was, it didn't work for me unless the host and the container had the exact same driver. In order to resolve this, you can run the following shell script if you're running on linux:

#!/bin/bash
version="$(glxinfo | grep "OpenGL version string" | rev | cut -d" " -f1 | rev)"
wget http://us.download.nvidia.com/XFree86/Linux-x86_64/"$version"/NVIDIA-Linux-x86_64-"$version".run
mv NVIDIA-Linux-x86_64-"$version".run NVIDIA-DRIVER.run
like image 136
HappyCry Avatar answered Nov 14 '22 22:11

HappyCry