Docker Community Forums

Share and learn in the Docker community.

Dockerfile and tkinter

Hello,
I am new to the forum. I searched for the tkinter topic but I could not find any. Would members of the forum help me out? I created a docker image with my tkinter app. However, when I tried to run my image, I keep receiving this error message
Traceback (most recent call last):
File “./aar.py”, line 19, in
aarWin = tk.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

here is my Dockerfile
FROM python:3
ADD aar.py /
CMD [ “python”, “./aar.py”]

I searched stackoverflow; it seems tkinter does not work in a container. Any suggestion is greatly appreciated!!

Regards

First, in order to run a python script in Docker is necessary to do it like this:

RUN python DeCoSTAR.py
Second, for your $DISPLAY error, you need first to specify a display to docker in order to use a GUI application. It usually can be done by adding

-e DISPLAY=$DISPLAY
-v /tmp/.X11-unix:/tmp/.X11-unix:rw
to docker run.