title: Running a Tkinter application inside a Docker container
body: <p>I wrote a small application in Python3 using <a href="https://docs.python.org/3/library/tkinter.html" rel="nofollow noreferrer">Tkinter</a>. I would like to containerize this application in order to reduce any installation and dependency hassle. </p>
  
  <p>I wrote the following Dockerfile:</p>
  
  <pre><code>FROM python:3.6-buster
  
  WORKDIR /home/python/app
  
  COPY . .
  
  RUN pip3 install -r requirements.txt
  
  # Install my package
  RUN python3 -m pip install --user --upgrade setuptools wheel
  RUN python3 setup.py install
  
  CMD [ "charts-app" ]
  </code></pre>
  
  <p>If I run the same commands outside Docker, everything works. </p>
  
  <p>Inside Docker, I am able to build the image, but when I run it, the following message is displayed:</p>
  
  <pre><code>File "/usr/local/lib/python3.6/tkinter/__init__.py", line 2023, in __init__
      self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
  _tkinter.TclError: no display name and no $DISPLAY environment variable
  </code></pre>
  
  <p>I understand that as the application is running inside the container, it has not directly access to a Graphical Interface. But, is there any way that I can "force" the container to use the <code>host</code> as its Graphical Interface? </p>