Run Any Linux GUI Program in a Web Browser

This is an application implementation of Docker to Run Any Linux GUI Program in a Web Browser.

In my “Building an Ubuntu Desktop in Docker” presentation we learned how to run a full Ubuntu desktop in Docker. To do that, we used the “docker build” command to build a custom docker image. We created a docker container from that custom image. In my “Docker Networking” presentation we saw how to create a Docker Network on your Main LAN or a VLAN. This time we are going to learn how to create a Docker application to run any Linux GUI program in a Web Browser.

This assumes you have an operational Docker host. On the docker host, create a “dockerfile”:

FROM ubuntu:20.04
RUN apt update && \
    apt install -y dia-common gnupg wget apt-transport-https software-properties-common && \
    wget -q -O- | apt-key add - && \
    add-apt-repository "deb focal main" && \
    apt update && \
    apt install -y xpra
CMD xpra start --start=dia --bind-tcp= --html=on && tail -f /dev/null

To create your custom container from your “dockerfile”:

docker build -t linux-command .

To create a container from the image:

docker run -d -p 18080:8080 --name=dia linux-command

You can instead use docker-compose by creating a docker-compose.yml

version: '3'
    container_name: dia
    image: linux-command
      - 18080:8080
    restart: unless-stopped

Invoke your docker-compose:

docker-compose up -d 

Although it is possible to use docker macvlan networks to provide dedicated container addresses for many applications, xpra requires redirection that cannot play well with X11/HTML5 redirection.

In the video, we created a Docker mcavlan network to run this container, but were unsucessful. Here are the commands:

ip route
docker network create -d macvlan --subnet= --gateway= -o parent=qvs0 exposed
docker network ls
docker run -d --name=dia --net=exposed --ip= linux-command