dockerコンテナ内などでqtを使用したアプリ使用時に以下のようなエラーが出る。
$ python test.py
qt.qpa.xcb: could not connect to display
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, webgl, xcb.
Aborted
以下のように仮想的なDISPLAYを用意する事で解決
sudo apt install -y xvfb
export DISPLAY=:1
nohup Xvfb -ac ${DISPLAY} -screen 0 1280x780x24 &
参考