Accessing X Apps from Container

I am troubleshooting some legacy Java web start UI applications. As the Java web start is no longer shipped with the latest JRE, I will not waste time to install it locally on my laptop and later remove it, instead, I will run it from a known container image that has the java web start binary still there.

If run the java web start in a container, then I also need an XWindow environment locally on my Macbook. Hmmm, not preferred. What I really want to do is to minimize any installation on my Macbook.

So Let’s run the X window environment inside the container, expose it through x11vnc, and access it from the Macbook using VNC Viewer.

First let's build Java web start together with the X windows app in the container.

FROM ibmjava:8-jre
RUN apt update && \
DEBIAN_FRONTEND="noninteractive" apt-get -y install xvfb x11vnc xterm fluxbox
CMD Xvfb -screen 0 1600x1200x24 -ac & \
DISPLAY=:0 startfluxbox & \
x11vnc -display :0 & \
while true; do sleep 120; done

On top of the base jre image, install the virtual x display server xvfb, the x11vnc server, and the lightweight window manager fluxbox.

Then launch the virtual display, start the fluxbox window manager, and run the x11vnc with the display :0. These apps will be all running in the background and we form an infinite loop for the container to be always up.

Build the image and tag it as javaws:1.0

Secondly, run the container with

docker run -d --name javaws -p 5900:5900 javaws:1.0

Lastly, we are ready to access the Xwindow environment in the container.

Tunnel the vnc port 5900 to be available on my Macbook.

ssh -NL 5900:192.168.10.xxx:5900 ubuntu@remote_ip

On the MacBook, install VNC Viewer, run it, and attach it to localhost:5900. We can access the bash shell,

Then launch the javaws,

Once we have this test working, I don’t think there are too many difficulties to let Kubernetes to manage it.

Cloud explorer