docker更新后X11显示停止工作

时间:2020-04-03 09:37:57

标签: windows docker x11

再次无法从docker容器连接到X11显示器。 我昨天将Windows 10的docker桌面(社区)更新为2.2.0.5,现在我的容器中的x11显示不再连接。 我正在使用此命令来测试matplotlib的tkagg后端(这是我一直使用的后端):

docker run -it test-docker python -c "import matplotlib.pyplot as plt; plt.plot([1], [2]); plt.show()"

即使ENV命令设置显示为:0.0也不起作用。所以我尝试了所有可能的组合

docker run -i -e DISPLAY=${host}:0.0 -t test-docker python -c "import matplotlib.pyplot as plt; plt.plot([1], [2]); plt.show()"

其中${host}localhost,``,以及ipconfig中列出的所有ip。

我已经确认XMing实例是可以的,因为我可以在WSL中的bash中运行该命令,并且呈现效果很好(使用DISPLAY = localhost:0.0)。

我的想法已经用光了,我真的需要帮助!

错误消息:_tkinter.TclError: couldn't connect to display ":0.0"

我还尝试添加--net=host -v /var/run/docker.sock:/var/run/docker.sock test-docker(来自X11 forwarding doesn’t work when image runs in docker machine but it works fine if the image is run w/o a docker machine),但没有成功。

我的最小Dockerfile(可在dockerhub上使用docker pull lucidnonsense/test-docker)是:

FROM ubuntu:latest
SHELL ["/bin/bash", "-c"]
ENV LANG=C.UTF-8 LC_ALL=C.UTF-8
ENV PATH /opt/conda/bin:$PATH
ENV TINI_VERSION v0.16.1

RUN apt-get update --fix-missing && \
    apt-get install -y wget bzip2 ca-certificates curl git && \
    apt-get clean && \
    rm -rf /var/lib/apt/lists/*

RUN wget --quiet https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda.sh && \
    /bin/bash ~/miniconda.sh -b -p /opt/conda && \
    rm ~/miniconda.sh && \
    /opt/conda/bin/conda clean -tipsy && \
    ln -s /opt/conda/etc/profile.d/conda.sh /etc/profile.d/conda.sh && \
    echo ". /opt/conda/etc/profile.d/conda.sh" >> ~/.bashrc && \
    echo "conda activate base" >> ~/.bashrc

ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /usr/bin/tini
RUN chmod +x /usr/bin/tini
RUN conda install -c conda-forge galsim
RUN conda install jupyter ipython matplotlib pyyaml
RUN conda install -c astropy aplpy


ENV DISPLAY :0
ENTRYPOINT [ "/usr/bin/tini", "--" ]
CMD [ "/bin/bash" ]

0 个答案:

没有答案