Docker Container Content with UI on Windows

Jul 4, 2019 General

Docker Container Content with UI on Windows

[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 Tomow

As a Managing Consultant, I am working at Alegri in Stuttgart/Germany. There I keep focusing with a team specialized in IoT, UX/Design and DevOps on preparing customers for the next digital future. I have been working as IT Consultant, IT Architect and lead developer with skills in .NetFramework, agile methodologies like Scrum and much more for nearly 2 decades. In the last few years I started focusing in IoT & Digitalization strategies in enterprise scenarios. Manly I used Microsofts Azure Cloud, to support customers in letting their visions become true. Sharing knowledge and practicing principles is something, that I like very much. Therefore I am also Co-Administrator of Azure-Meetup group in Stuttgart, where I'd also like to share my experiences. With this I was awarded in november by Microsoft as a MVP (Most Valuable Professional).

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.