Skip to content

Instantly share code, notes, and snippets.

@tstellanova
Last active September 25, 2019 22:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tstellanova/517bde40ba76a92536dc582511d85580 to your computer and use it in GitHub Desktop.
Save tstellanova/517bde40ba76a92536dc582511d85580 to your computer and use it in GitHub Desktop.
Access linux docker container gui from OSX

How to display a gui from a linux container on a host Mac OSX machine:

  • Ensure that xquartz is installed, using homebrew:
brew install xquartz socat

You may need to log out and log back in if xquartz was not already installed

  • Open xquartz:
open -a Xquartz

and configure "Allow connections from network clients" to ON.

  • Ensure that socat is installed, and then run a socat bridge between TCP port 6000 (default for X window system) and the unix domain socket for the Mac's xquartz display.
brew install socat
socat TCP-LISTEN:6000,reuseaddr,fork UNIX-CLIENT:\"$DISPLAY\"

This bridge will run indefinitely, until you kill it.

  • In another shell, get the IP address of your Mac OSX machine, eg:
ifconfig en0
...
inet 10.0.1.46 netmask 0xffffff00 broadcast 10.0.1.255
...
  • Run your docker container, providing the DISPLAY environment variable that will be used by the container to access your mac's X windows display.
docker run -it --rm -e DISPLAY=10.0.1.46:0 --name=running-buster -v/Users/todd/Documents/proj/busterama/stuff:/root/stuff buster-runner
  • Assuming your container opens a GUI, it should appear on your Mac's display
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment