1

I wrote an app in Python with a Tkinter GUI and I am trying to deploying it with Docker. I am having a hell of a time trying to figure out how to get it to work.

When I tried to run it locally, I got a "no display name and no $DISPLAY environment variable" error.

I poked around found out I could fix that by adding this to my python script:

if os.environ.get('DISPLAY','') == '':
    print('no display found. Using :0.0')
    os.environ.__setitem__('DISPLAY', ':0.0')

Now I get _tkinter.TclError: couldn't connect to display ":0.0".

I tried adding -u=$(id -u $USER):$(id -g $USER) -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix:rw -v $(pwd)/app:/app --rm <app name> to my launch script (as suggested here) but this didn't fix anything.

I know this is a question that has been asked more than a few times, but it's an error that comes up a lot, and the problem seems to have a number of solutions across versions and platforms. Thanks.

steadynappin
  • 409
  • 3
  • 14
  • [Can you run GUI applications in a Linux Docker container?](https://stackoverflow.com/questions/16296753/can-you-run-gui-applications-in-a-linux-docker-container) has a lot of options (some better and some worse) but it's complicated and not especially portable to non-Linux systems; would it make more sense to run this application directly on the host and not in a container? – David Maze Nov 15 '22 at 01:44
  • ha yeah i've been down this road unfortunately but thanks ... do you happen to know if there's a way to use a web browser to display a Tkinter app? – steadynappin Nov 15 '22 at 18:08

0 Answers0