Skip to content

Instantly share code, notes, and snippets.

@RELATO
Last active June 28, 2017 14:38
Show Gist options
  • Save RELATO/481c3e7bc82c52429909c1b66fd3f435 to your computer and use it in GitHub Desktop.
Save RELATO/481c3e7bc82c52429909c1b66fd3f435 to your computer and use it in GitHub Desktop.
Run a graphical app in docker on OSX/Windows/Linux

Run a graphical app in docker on OSX

From: https://gist.github.com/netgusto/931085fc3673b69dd15a1763784307c5

Note: Replace 192.168.0.5 below by your own interface ip

mac $ socat TCP-LISTEN:6000,reuseaddr,fork UNIX-CLIENT:\"$DISPLAY\"
mac $ docker run --device=/dev/tty0 -e DISPLAY=192.168.0.5:0 -i -t ubuntu /bin/bash
ubuntu $ apt-get update && apt-get install -y firefox
ubuntu $ firefox

If socat is not installed on your mac, install it with brew: brew install socat.

If XQuartz is not installed on your mac : https://www.xquartz.org/

If you get "Couldn't open libGL.so.1: libGL.so.1: cannot open shared object file: No such file or directory" while running the program (here, firefox) : apt-get install -y libglu1-mesa

Solution is not secure (publishes a TCP port linking to your X11 display socket).

Extracted from: moby/moby#8710

RELATO Tips:

To avoid security issues (behind firewall) bypass with:

xhost +

Windows you may install XMing (small, fast, just works)

https://sourceforge.net/projects/xming/?source=typ_redirect or (alternative) http://mobaxterm.mobatek.net/

mac docker command example:

docker run -it -e DISPLAY=192.168.2.1:0.0 -v ~/projects:/data --net ap_app_net --ip 172.16.232.10 --name devtools relato/devtools

Windows 10 docker command example:

cd \
mkdir projects
docker run -it -e DISPLAY=192.168.2.2:0.0 -v //c/projects:/data --name devtools relato/devtools
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment