Skip to content

Instantly share code, notes, and snippets.

@stonehippo
Last active December 6, 2021 00:21
Show Gist options
  • Star 21 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save stonehippo/2c2b0972b7d199c78fb94fa9b1be1f5d to your computer and use it in GitHub Desktop.
Save stonehippo/2c2b0972b7d199c78fb94fa9b1be1f5d to your computer and use it in GitHub Desktop.
Getting X11 GUI applications to work on OS X with Docker

Getting X11 GUI applications to work on OS X with Docker

$ brew install socat
$ brew cask install xquartz <--- assuming you don't already have XQuartz installed some other way
$ open -a XQuartz <--- start an XQuartz session

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

In a new terminal:

$ inconfig

Look for the IP address assigned to your Docker VM; the interface will be something like vboxnet0 or vboxnet1

$ docker run --rm -e DISPLAY=[IP address of vboxnet0]:0 [image] [command]

For example, to run the Arduino IDE, I've used

$ docker run --rm -e DISPLAY=192.168.99.1:0 davechick/arduino-dev arduino

See moby/moby#8710 for more info

@kiki67100
Copy link

Hello
I make a little script to do that :

https://gist.github.com/kiki67100/5e1568ac783e8e4942b672f1090db2cd

Thanks for your script

@stonehippo
Copy link
Author

s/XQuarts/XQuartz/

Fixed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment