title: docker _tkinter.TclError: couldn't connect to display
body: <p>ubuntu 16.04 ,
  nvidia-docker installed,
  a tensorflow container running,
  python 2.7</p>
  
  <p>i want to run a simple python code inside the container. shown as below</p>
  
  <pre><code>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()
  </code></pre>
  
  <p>but when i run this, this error comes</p>
  
  <blockquote>
    <p>_tkinter.TclError: no display name and no $DISPLAY environment variable</p>
  </blockquote>
  
  <p>and according to this site <a href="https://github.com/moby/moby/issues/8838" rel="noreferrer">https://github.com/moby/moby/issues/8838</a> 
  i committed my container to an image, and run it again with the -e flag:  </p>
  
  <blockquote>
    <p>-e DISPLAY=:0.0</p>
  </blockquote>
  
  <p>but here comes the error:</p>
  
  <blockquote>
    <p>_tkinter.TclError: couldn't connect to display :0.0</p>
  </blockquote>
  
  <p>i'm not using ssh to login the container.
  could anyone can give me advice about it? </p>