首页 > 解决方案 > Python 脚本(PyQt5 GUI 组件)在 Docker 容器中运行且未连接到显示器

问题描述

我有一个 Python 脚本,它使用 PyQt5 GUI 根据用户查询数据库的输入设置不同的变量。我在 Docker 中有容器,一切都很好,但是当我用docker run surefire_loader它运行容器时,会出现以下错误:QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root' qt.qpa.screen: QXcbConnection: Could not connect to display Could not connect to any X display.

我的 Dockerfile 看起来像这样:

FROM python:3.6

ADD salesforce_extract_dict.py /
ADD config.py /
ADD requirements.txt /

RUN apt-get update && apt-get -qq install libgl1-mesa-glx
RUN pip install --trusted-host pypi.org --trusted-host 
files.pythonhosted.org -r requirements.txt

CMD [ "python", "./salesforce_extract_dict.py" ]

我目前正在 Mac 上执行此操作,但我希望将其移至 Windows PC 进行生产 - 如果此信息有帮助的话。

可能是什么特殊问题,如何让 GUI 连接到本地机器的显示器?

标签: pythondockeruser-interfacedockerfilepyqt5

解决方案


推荐阅读