Skip to content

Instantly share code, notes, and snippets.

@dra1n
Created May 20, 2017 08:14
Show Gist options
  • Select an option

  • Save dra1n/c7cf01e9dffc9ee27a8e2d3f4b757a3a to your computer and use it in GitHub Desktop.

Select an option

Save dra1n/c7cf01e9dffc9ee27a8e2d3f4b757a3a to your computer and use it in GitHub Desktop.
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment