python – docker _tkinter.TclError:无法连接到显示
ubuntu 16.04,安装了nvidia-docker,一个张量流容器运行,python 2.7
我想在容器中运行一个简单的python代码.如下所示
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()
但是当我运行它时,会出现此错误
_tkinter.TclError: no display name and no $DISPLAY environment variable
并根据这个网站https://github.com/moby/moby/issues/8838我将容器提交到图像,然后使用-e标志再次运行它:
-e DISPLAY=:0.0
但是这里出现了错误:
_tkinter.TclError: couldn’t connect to display :0.0
我没有使用ssh登录容器.任何人都可以给我建议吗?