问题描述
ubuntu 16.04,安装了
nvidia-docker,运行了
a tensorflow容器,
python 2.7
ubuntu 16.04 ,nvidia-docker installed,a tensorflow container running,python 2.7
我想运行一个简单的容器内的python代码。如下所示
i want to run a simple python code inside the container. shown as below
from tkinter import *
master = Tk()
canvas_width = 80
canvas_height = 40
w = Canvas(master,
width=canvas_width,
height=canvas_height)
w.pack()
y = int(canvas_height / 2)
w.create_line(0, y, canvas_width, y, fill="#476042")
mainloop()
但是当我运行此命令时,会出现此错误
but when i run this, this error comes
,并根据此站点
i将我的容器提交给图像,然后使用-e标志再次运行它:
and according to this site https://github.com/moby/moby/issues/8838i committed my container to an image, and run it again with the -e flag:
但出现错误:
我没有使用ssh登录容器。
谁能给我建议吗?
i'm not using ssh to login the container.could anyone can give me advice about it?
推荐答案
这是因为容器无法访问主机的x11套接字。因此在执行docker run时,需要包含这两个标志。
This is because the container couldn't access the x11 socket of the host. so when doing the docker run, need to include these two flag.
-e DISPLAY = unix $ DISPLAY
-e DISPLAY=unix$DISPLAY
之后,我们需要执行另一项操作。因为X11的默认设置仅允许本地用户打印。因此我们需要将其更改为所有用户。
and after this, we need to do another operation. because the default settings of X11 only allows local users to print. so we need to change this to all users.
$ xhost +
$ xhost +
然后问题解决了。 ^ ^
then the problem solved. ^ ^
这篇关于码头工人_tkinter.TclError:无法连接显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!