I wrote a small application in Python3 using Tkinter. I would like to containerize this application in order to reduce any installation and dependency hassle.
I wrote the following Dockerfile:
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" ]
If I run the same commands outside Docker, everything works.
Inside Docker, I am able to build the image, but when I run it, the following message is displayed:
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
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 host
as its Graphical Interface?