How to use GUI apps in linux docker container from Windows Host
with X11!
1. Set up X server on windows
Install x server. I like the x server from VcXsrv but there are others you can try like X Ming.
choco install vcxsrv
Launch the x server. Run XLaunch from start menu, or if not found, try looking for xlaunch.exe at the default install location “C:\Program Files\VcXsrv\xlaunch.exe”
Go with all the default settings, however do note to check “Disable access control”
X server should show up in your tray icons.
2. Execute a linux container
docker run -ti ubuntu /bin/bash
To start a container from the ubuntu image and run an interactive shell
3. Link container’s DISPLAY to use windows host
Get the IP of your windows host
ipconfig
If you’re like me using windows docker toolbox, the host IP address is likely 192.168.99.1
Lets set the DISPLAY env variable in the container.
export DISPLAY=192.168.99.1:0.0
The format of the display variable is [host]:<display>[.screen]
. When X11 forwarding over SSH, the TCP port number to open is 6000 + <display>
. For more info see this unix stack exchange page.
4. Test out some x apps!
apt-get install x11-apps
To install a bunch of tiny gui apps like xeyes and xclock
xeyes
If all works well…
A pair of eyes will pop out!