Docker Container Content with UI on Windows

Jul 4, 2019 General
[Reading Time: 3 minutes]

For a little project I needed access to an application running in Linux. But while working on a windows machine, I was not able to.

But knowing, that I had a linux installation as base for running docker for windows – Mobi linux – I tried to get this working with a container. The problem here is only, there is no native support, running an application with UI from a container.

After some researches in WWW, I found some solution to that. So, take this simply as lookup information.

  1. First you need VcXsrv. This is a X-Server running on a Windows OS, that can display Linux GUI-Application from a Unix/Linx machine. It redirect mouse and keyboard input to that application for interacting with that.
    You can download this here: https://sourceforge.net/projects/vcxsrv/
    1. Please use following configuration steps, to get happy
    2. Start XLaunch (WIN-Key -> type xlaunch -> select result)
    3. Now select the configuration as shown (It’s german UI, but the buttons are in most other languages at the same place )
    4. So hit continue/next until you see a “save configuration” button (Save it and start next time via config-file)
    5. The x-server is now launched and hides into you toolsbar
  2. As a required step, Docker for Windows should be installed and configured to your needs. (How: https://docs.docker.com/docker-for-windows/install/)
  3. Next we need a docker container with an application. For the sake of simplicity, I like to use a container, that can open a browser. Think of the use case having a browser session, that can be detroyed after stopping/removing the container
    1. Create the docker file:
      FROM ubuntu:14.04
      RUN apt-get update && apt-get install -y firefox
      CMD /usr/bin/firefox
    2. Build your image
      docker build -t firefox .
    3. Now prepare the connection between x-server and container using PowerShell
      set-variable -name DISPLAY -value <your IP>:0.0
      As you can see, I added the DISPLAY variable, that is needed to interact with our previously installed X-Server
      (It’s the target IP address – <..> are placeholders – and Display Configuration)
      Your IP address can be found in Adapter-Configuration or via ipconfig, and so on…..
    4. Run your container
      docker run -ti –rm -e DISPLAY=$DISPLAY firefox

      …and here we go!

By Thomas

As Chief Technology Officer at Xpirit Germany. I am responsible for driving productivity for our customers by a full stack of dev and technology in modern times. But I not only care for technologies from Microsofts stack like Azure, AI, and IoT, but also for delivering quality and expertise with DevOps

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.