This page will describe how to test docker X-Windows applications for Linux applications with graphical user interface. The example will install default x11 apps like a clock, but also show how to run a game like MegaGlest in Docker (this is just a demo as running games in Docker is slow).

Build MegaGlest Docker image

The Dockerfile below will install MegaGlest for Linux which is currently version 3.12.0. To play with yourself on a Windows machine you must install the same version:

To start MegaGlest in Window mode add the –fullscreen=false to the Windows desktop shortcut, this is good for testing your own MegaGlest modules on an single machine.

“C:\Program Files (x86)\MegaGlest\megaglestx64.exe” –fullscreen=false

Before you start disable “Experimental features” under “Daemon” in Docker Windows tray icon and restart Docker, this can fix issues with starting image.

To build this Docker MegaGlest image, first create a folder like c:\data\git\lisbergio\private\docker\megaglest and the copy the lines below to a text file named Dockerfile in this folder:

FROM openjdk
RUN cd /tmp
RUN apt-get update
RUN apt-get -y install sudo
RUN useradd -m docker && echo “docker:docker” | chpasswd && adduser docker sudo
RUN echo “docker ALL=(ALL) NOPASSWD:ALL” > /etc/sudoers.d/docker
USER docker

RUN sudo apt-get update
RUN sudo apt-get -y install megaglest
RUN sudo apt-get -y install x11-apps
RUN sudo apt-get -y install nano
RUN sudo apt-get -y install openssh-server

RUN sudo chmod 666 /etc/ssh/sshd_config
RUN sudo echo “PermitRootLogin no” >> /etc/ssh/sshd_config
RUN sudo echo “AllowUsers docker” >> /etc/ssh/sshd_config
RUN sudo echo “PasswordAuthentication yes” >> /etc/ssh/sshd_config
RUN sudo echo “UsePrivilegeSeparation no” >> /etc/ssh/sshd_config
RUN sudo echo “ListenAddress” >> /etc/ssh/sshd_config
RUN sudo echo “Port 2200” >> /etc/ssh/sshd_config
RUN sudo echo “X11DisplayOffset 10” >> /etc/ssh/sshd_config
RUN sudo echo “X11UseLocalhost yes” >> /etc/ssh/sshd_config
RUN sudo chmod 644 /etc/ssh/sshd_config
RUN sudo service ssh –full-restart

EXPOSE 61357-61366

RUN echo ‘#!/bin/bash’ > /home/docker/
RUN echo “export IP=$(sudo ip address | grep eth0 | grep -o -P ‘(?<=inet\ ).*(?=\/)’)” >> /home/docker/
RUN echo “export DISPLAY=” >> /home/docker/
RUN echo “export SDL_VIDEO_X11_VISUALID=0x022” >> /home/docker/
RUN echo “sudo service ssh start” >> /home/docker/
RUN echo ‘bash’ >> /home/docker/
RUN chmod u=rwx,g=rx,o= /home/docker/

CMD [“/home/docker/”]

Now start a PowerSheel command line tool a type:

cd c:\data\git\lisbergio\private\docker\megaglest

docker image rm -f lisberg_io_megaglest

docker build -t lisberg_io_megaglest:latest .

Tag and push image to Docker account

If you want to tag the image and push it to your Docker account, do something similar to:

docker login -u olioaps -p <password>

docker tag lisberg_io_megaglest:latest olioaps/private:lisberg_io_megaglest

docker push olioaps/private:lisberg_io_megaglest

Install Xming server

Go to and install the Xming server. Install Xming with defaults, but select to add desktop shortcut. Right click desktop shortcut and add -ac and relevant screen size or number of monitor:

“C:\Program Files (x86)\Xming\Xming.exe” :0 -clipboard -fullscreen -depth 32 -ac -screen 0 1920×1080+0+0@1

Or if you prefer multiple Windows.

“C:\Program Files (x86)\Xming\Xming.exe” :0 -clipboard -multiwindow -depth 32 -ac -screen 0 1920×1080+0+0@1

Run MegaGlest Docker image

To run MegaGlest Docker image with default command script that starts ssh service, exports the DISPLAY and SDL_VIDEO_X11_VISUALID environment variables.

docker run -p 2200:2200 -p 61357-61366:61357-61366 -it lisberg_io_megaglest

When the Linux command prompt is ready, you start MegaGlest with:



You can find information about the MegaGlest Linux files here

If you for some reason need you can run the Docker image with Bash to avoid the ssh service from starting automatically at startup.

docker run -p 2200:2200 -p 61357-61366:61357-61366 -it lisberg_io_megaglest bash

Type “env” i Bash to see the DISPLAY settings, which must match your Xming server setting like for example “0.0”.

export DISPLAY=

If you need to create an .Xauthority file in the docker users home folder, then just run ssh in a DOS command prompt with -X option

ssh -X docker@localhost -p 2200

If you connect to MegaGlest Docker image with SSH client like PuTTY, you must set the proper environment variables for yourself:

export DISPLAY=
export SDL_VIDEO_X11_VISUALID=0x022

In MegaGlest top menu, under options, network you can change the server port if there is a port conflict for some reason.