Skip to content

Instantly share code, notes, and snippets.

@zst123
Created October 29, 2017 13:56
Show Gist options
  • Save zst123/9c490c9ff090595997619762b6d1d1d1 to your computer and use it in GitHub Desktop.
Save zst123/9c490c9ff090595997619762b6d1d1d1 to your computer and use it in GitHub Desktop.
Setup XQuartz on Mac to run Docker GUI apps.
# References:
# http://sourabhbajaj.com/blog/2017/02/07/gui-applications-docker-mac/
# https://forums.docker.com/t/how-to-run-gui-apps-in-containiers-in-osx-docker-for-mac/17797/21
# https://fredrikaverpil.github.io/2016/07/31/docker-for-mac-and-gui-applications/
# Install XQuartz
brew cask install xquartz
# Allow network connections
defaults write org.macosforge.xquartz.X11 nolisten_tcp 0
# Don't launch terminal when starting XQuartz
defaults write org.macosforge.xquartz.X11 app_to_run /usr/bin/true
# Launch XQuartz
open -a XQuartz
# Add this PC's hostname
xhost + $(hostname)
# Run a Docker GUI container
docker run --rm -d -e DISPLAY="$(hostname)":0 -v /tmp/.X11-unix:/tmp/.X11-unix --name vscode jess/vscode
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment