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.
-
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/- Please use following configuration steps, to get happy
- Start XLaunch (WIN-Key -> type xlaunch -> select result)
- Now select the configuration as shown (It’s german UI, but the buttons are in most other languages at the same place )
- So hit continue/next until you see a “save configuration” button (Save it and start next time via config-file)
- The x-server is now launched and hides into you toolsbar
- As a required step, Docker for Windows should be installed and configured to your needs. (How: https://docs.docker.com/docker-for-windows/install/)
-
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
- Create the docker file:
FROM ubuntu:14.04
RUN apt-get update && apt-get install -y firefox
CMD /usr/bin/firefox - Build your image
docker build -t firefox . - 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….. -
Run your container
docker run -ti –rm -e DISPLAY=$DISPLAY firefox…and here we go!
- Create the docker file: