When I tried to display an image with matplotlib etc. in the Docker container, I wrote it. I am doing it in Ubuntu 16.04.6 LTS environment.
[problem] After Docker run, enter the container and plot.show () with matplotlib, no image is displayed and the command ends. Or
docker _tkinter.TclError: couldn't connect to display _tkinter.TclError: no display name and no $DISPLAY environment variable _tkinter.TclError: couldn't connect to display :0.0 I get an error like this.
[approach] ① First, transfer the following command to the terminal
$sudo apt-get install x11-xserver-utils
$xhost +
② When doing docker run, add the following to the options
-v /tmp/.X11-unix:/tmp/.X11-unix
-e DISPLAY=unix$DISPLAY
③ If matplotlib is not in the container, in interactive mode after starting the container
pip install matplotlib
④ If tkinter is not in the container, in interactive mode after starting the container
apt-get update
apt-get install python3-tk
When installing python3-tk, there was a question about the area of residence.
Now the image is displayed well even in the container. : family:
Recommended Posts