Last Updated: May 20, 2017
· dra1n

Run GUI apps in containier in OSX (docker for mac)

Run XQuartz

  • Update preferences 'Security' tab - turn on 'Allow connection from network clients'
  • Restart XQuartz and then check to see that it is listening on port 6000:
lsof -i :6000

Install socat

And run it so it will wait for connections and then pass them over to XQuartz.

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

Get your local machine's IP:

ip=$(ifconfig en0 | grep inet | awk '$1=="inet" {print $2}') && echo "My IP is: $ip"

Allow the local machine to talk to XQuartz

xhost + ${ip}

Run your docker host:

docker run --rm -it -e DISPLAY=${ip}:0 -v /tmp/.X11-unix:/tmp/.X11-unix --name firefox jess/firefox

Now you can do stuff described here