Running Legacy Windows Desktop Applications Under Wine Directly in the Browser Via XPRA Containers

Okay, so here’s another way of trying to run legacy Windows applications under Wine in a Docker container via browser.

This variant improves on Running RobotLab (Legacy Windows App) Remotely or Locally in a Docker Container Under Wine Via RDP by not requiring the user to update Wine and by launching directly into either the RobotLab application or the Neural application.

If you have Docker running, you should be able to just type:

#Run RobotLab (default)
docker run --name tm129robotlab --shm-size 1g -p 3395:10000 -d ousefuldemos/tm129robotics-xpra-html5

#Run RobotLab (explicitly)
docker run --name tm129robotlabx --shm-size 1g -p 3396:10000 -e start=robotlab -d ousefuldemos/tm129robotics-xpra-html5

#Run Neural (explicitly)
docker run --name tm129neuralx --shm-size 1g -p 3397:10000 -e start=neural -d ousefuldemos/tm129robotics-xpra-html5

Here’s the Dockerfile (also see the repo):

#This container has been removed
#and the original repo archived (it used an old Linux base container)
#FROM lanrat/docker-xpra-html5

#I forked the lanrat/docker-xpra-html5 and rebuilt it using ubuntu:bionic
FROM ousefuldemos/docker-xpra-html5

USER root

#Required to add repo
RUN apt-get update && apt-get install -y software-properties-common wget

#Install wine
RUN dpkg --add-architecture i386

RUN wget -qO- | apt-key add -
RUN apt-add-repository 'deb bionic main'
RUN apt update && apt-get install -y --install-recommends winehq-stable

#Install the wine packages wine wants to load if they aren't already there
#There are lots of warnings in the install but they seem to work in use?
RUN mkdir -p /home/user/.cache/wine
RUN wget -O /home/user/.cache/wine/wine-mono-4.8.1.msi
RUN wget -O /home/user/.cache/wine/wine_gecko-2.47-x86.msi
RUN wget -O /home/user/.cache/wine/wine_gecko-2.47-x86_64.msi

USER user
RUN wine msiexec /i /home/user/.cache/wine/wine_gecko-2.47-x86_64.msi
RUN wine msiexec /i /home/user/.cache/wine/wine_gecko-2.47-x86.msi
RUN wine msiexec /i /home/user/.cache/wine/wine-mono-4.8.1.msi

USER root

#Use the recipe in
#for starting with RobotLab

#Copy over Win application folders
COPY Apps/  /opt/Apps

#Add some start commands

ADD /usr/local/bin/robotlab
RUN chmod +x /usr/local/bin/robotlab

ADD /usr/local/bin/neural
RUN chmod +x /usr/local/bin/neural

#Pulseaudio also has a switch in cmd
#Can't get this working atm...
#Does it even make sense to try?
#i.e. can XPRA HTML be used to play audio in a browser anyway?
#RUN apt-get install -y pulseaudio

#Go back to user...
USER user

ENV start robotlab

#Start with robotlab
CMD xpra start --bind-tcp= --html=on  --exit-with-children --daemon=no --xvfb="/usr/bin/Xvfb +extension Composite -screen 0 1920x1080x24+32 -nolisten tcp -noreset" --pulseaudio=no --notifications=no --bell=no --start-child=${start}

#Example image pushed as 
#docker build -t ousefuldemos/tm129robotics-xpra-html5 .
#Default runs robotlab
#docker run --name tm129x --shm-size 1g -p 3395:10000 -d ousefuldemos/tm129robotics-xpra-html5
#docker run --name tm129x --shm-size 1g -p 3395:10000 -e start=robotlab -d ousefuldemos/tm129robotics-xpra-html5

One thing I’s started wondering now is: could we run this via a Jupyter notebook UI using jupyter-server-proxy (I tried, and it doesn’t seem to work atm: the proxy just goes into an infinite redirect loop?); or launch it as a standalone container using JupyterHub Dockerspawner and a Dockerfile shim to change the start CMD so things start on port 8888 (a naive attempt at that didn’t seem to work either).

At the very least, this seems to offer a reasonably natural way of launching a containerised desktop application directly into the browser?

(It would be useful to know if PulseAudio can be used to play sound from a container launched on something like Digital Ocean through the XPRA HTML5 desktop viewed in a browser before I waste any more time chasing that, and if so, it would be really handy to see a minimal working example Dockerfile ;-)

I’m guessing it should also work in the Google Cloud Run serverless container context [howto]? I still need to try this out…

Author: Tony Hirst

I'm a Senior Lecturer at The Open University, with an interest in #opendata policy and practice, as well as general web tinkering...

%d bloggers like this: