Skip to content

docker_graphics_macos

Claire Guépin edited this page Apr 16, 2025 · 26 revisions

MacOS configuration to enable graphics of Docker of linux image

  • XQuartz installation
  • restart computer
  • install Docker with your CPU version
  • in the Docker application go to preferences > resources and add more memory
  • X11 preference security, select "Allow connection from network clients"
  • restart Docker application
  • retrieve your <IP> address (inet) in a Terminal shell with:
ifconfig en0
  • open a Terminal shell within the XQuartz application (only needed for this step) and add
xhost +

or

xhost <IP>
  • add this option to the docker run command when creating a container
-e DISPLAY=<IP>:0

Check

python -m tkinter

Problems

If this does not work, one solution is to run socat, to forward a TCP port to a UNIX socket. You'll need to install socat, ex. brew install socat. Then, in a terminal

socat TCP-LISTEN:6001,reuseaddr,fork UNIX-CLIENT:\"$DISPLAY\"

Then run the docker, for instance

docker run -p 8888:8888 -e DISPLAY=host.docker.internal:1.0 -it --rm -v $PWD:/home grandlib/dev

Reference

Watch this video

Clone this wiki locally