Python Tkinter in Docker .TclError: couldn't connect to display
<p>I am new to python and am trying to build a small app. It needs to be a GUI app and I was wanting to containerise it with docker. I am getting the following error and can not find a solution</p>

<pre><code>No protocol specified
No protocol specified
Traceback (most recent call last):
  File "tkinker.py", line 7, in &lt;module&gt;
    tinker = Tk()
  File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1818, in __init__
    self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
_tkinter.TclError: couldn't connect to display ":0.0"
</code></pre>

<p>It starts locally but wont start in docker. My OS is Xubuntu.</p>

<p>I have created a sample app (below), see run-test.sh <a href="https://github.com/jeremysells/test/tree/master/docker-tkinter" rel="nofollow">https://github.com/jeremysells/test/tree/master/docker-tkinter</a></p>

<p>You'll have to set DISPLAY in the container. You can add it as an argument to the docker run command like this:</p>

<pre><code>docker run -ti -e DISPLAY=$DISPLAY blah-image blah-command
</code></pre>

<p>DISPLAY should be set in the Xubuntu shell you are running the command from.</p>

python ubuntu docker tkinter xfce