---
# System prepended metadata

title: docker qt xcb 問題

---

# docker qt xcb 問題
在docker中執行會開啟qt界面的程式發現以下報錯:
```
qt.qpa.plugin: Could not find the Qt platform plugin "offscreen" in "/opt/conda/lib/python3.8/site-packages/cv2/qt/plugins"
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: xcb.

Aborted (core dumped)
```
## 解法
* 先退出容器
* 執行`xhost +`
* 進入容器後即可執行
* 我的docker-compose.yaml檔:
```yaml=
services:
    itri-bev:
        stdin_open: true
        tty: true
        devices:
            - /dev/dri
        group_add:
            - video
        volumes:
            - /tmp/.X11-unix:/tmp/.X11-unix
            - ./:/src
        deploy:
            resources:
                reservations:
                    devices:
                        - driver: nvidia
                          count: all
                          capabilities:
                              - gpu
        environment:
            - DISPLAY=$DISPLAY
            - QT_X11_NO_MITSHM=1
            - NVIDIA_VISIBLE_DEVICES=all
            - NVIDIA_DRIVER_CAPABILITIES=all
        container_name: itri-bev-container
        build: .
        image: frakw/itri-bev:x64
        command: /bin/bash
```
