22

I'm trying to use Windows 10 as my host and run Docker containers that contain gui based applications and display them using X11 forwarding or something similar. Pretty much all of the information I've found online deal with Linux Host to Linux Container (example - http://fabiorehm.com/blog/2014/09/11/running-gui-apps-with-docker) where the socket / x11 authority are exposed. Other information I've found is from previous implementations of Boot2Docker / Windows where virtualbox was required as part of the setup procedure and required VNC.

Basic setup currently, does anyone know what has to be adjusted to get Firefox to display within a window on the host system? --

Start an XMing server on Windows 10 host

Dockerfile

FROM ubuntu:14.04
RUN apt-get update && apt-get install -y firefox
CMD /usr/bin/firefox

Commands

PS> docker build -t firefox .
PS> set-variable -name DISPLAY -value localhost:0.0
PS> docker run -ti --rm -e DISPLAY=$DISPLAY firefox

Thanks

Fitz
  • 243
  • 1
  • 2
  • 7
  • 2
    Did you manged to do it? and Do you have a blog post or document that how you did it? – Haseeb Asif Sep 17 '17 at 10:31
  • 1
    Yes - the comments on the accepted answer detail how I did it. I used the code from my question except in the commands I changed the second line for exporting the display to use my host ip address instead of the localhost term. Then I modified one of the settings on the XMing application when starting it up to have 'No Access Control' checked – Fitz Sep 18 '17 at 14:46

1 Answers1

10

You'll need to set DISPLAY to something other than localhost. The container has its own localhost interface, so your X11 client will attempt to connect to itself instead of to your host.

Instead, you can pass in an IP address of your windows machine's network adapter. The container will be able to connect to that. You'll also need to have your X11 server configured to listen on that interface.

programmerq
  • 6,262
  • 25
  • 40
  • 1
    That was it, works like a charm now! thanks! Good way to test this removing the docker container from the equation is to get it working with windows bash and firefox. Doing an $export DISPLAY=(ip_address):0 and then running firefox from bash I was able to tell the x server and interface were correct before involving the container in to the mix – Fitz Oct 13 '16 at 20:30
  • 2
    Also - if using XMing as your x server, then on, based on the code I provided, you should keep Display Number as 0 and make sure 'No Access Control' is **checked** on the 'Additional Paramters' screen – Fitz Oct 13 '16 at 20:39
  • Note that it must be the host machines network adapter _as seen from the container_. For non-bridged networks this may be something completely else than the IP-address the host use to talk to the world. Docker Desktop use a 10.x.y.z network by default – Thorbjørn Ravn Andersen Oct 05 '20 at 11:46