Host Machine: Windows 10 Enterprise
Application: Docker Desktop for Windows
Container option: Linux Containers
I have a python script basically a countdown timer. The code can be found from the website https://www.geeksforgeeks.org/create-countdown-timer-using-python-tkinter/ I named this source file as timer.py and able to run it using python.exe
I am trying to containerize the same using docker. I have pulled in Python3.6 image from the docker hub. My docker file is as below.
FROM python
COPY . /opt/
WORKDIR /opt
ENTRYPOINT ["python", "timer.py"]
I built the image and when I run the container I get hte following error
Traceback (most recent call last):
File "timer.py", line 7, in <module>
root = Tk()
File "/usr/local/lib/python3.8/tkinter/__init__.py", line 2261, 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 don't understand the error, I have searched through StackOverflow with similar error couldn't find a solution for my problem. Any help is greatly appreciated.
note: 1. I am able to containerize and run a simple python script with just a print("hello world"), but with Tkinter I am not able to 2. For some reason not able to pull in images using the windows containers option, so trying in Linux containers.