Skip to main content

Raymii.org Raymii.org Logo

Quis custodiet ipsos custodes?
Home | About | All pages | RSS Feed | Gopher

Running gnash on Ubuntu 20.04 (in Docker with X11 forwarding)

Published: 05-07-2020 | Author: Remy van Elst | Text only version of this article


Table of Contents


As you might have noticed, I'm slowly updating servers and workstations to Ubuntu 20.04, and as always with major upgrades, things break or are removed. Earlier this week I fixed up pygopherd and today I'll get gnash running again. Gnash is not updated since 2011 and therefore, finally, removed from the Ubuntu 20.04 repositories.

Compiling gnash from source proved to be a lot of effort due to gstreamer dependencies and after a few hours I thought, why not just spin up a Ubuntu 18.04 Docker container, install gnash and forward X11. That took just about 10 minutes and now I'm happily running gnash again. In this tutorial I'll show you how to setup gnash in a docker container with x11 forwarding and host networking.

Why run gnash?

Some of my $dayjob work depends on gnash, although it's actively being replaced with QT. Gnash is a linux flash player, in our case runs on the framebuffer of an embedded device.

For development I sometimes need to run gnash on my workstation with an SSH port forward to a development board. I can then locally interact with the UI. Also, the development board does not require a screen, which saves time and space in development setup.

If you like this article, consider sponsoring me by trying out a Digital Ocean VPS. With this link you'll get $100 credit for 60 days). (referral link)

Here is a picture of gnash running on Ubuntu 20.04, via a local docker container:

gnash in docker

Here is gnash running on my Ubuntu 18.04 workstation, as you can see the window manager theme and styling is missing in Docker, but I can live with that. I do miss my CDE window border though:

gnash

Both screenshots are showing the user interface for one of the coffee machines we develop software for at $dayjob. One shows the user facing menu and one shows the service menu, where a machine operator in this case can view all sorts of counters (beverage, user defined, components).

Gnash in Docker

Lets get started. I assume you have docker installed already. Most of the X11 forwarding is taken from the article by Fabio Rehm.

Create a folder for your new docker image:

mkdir gnash-docker
cd gnash-docker

Create a Dockerfile:

vim Dockerfile

Paste the following in it:

FROM ubuntu:18.04

RUN apt-get update && apt-get install -y sudo
RUN apt-get update && apt-get install -y gnash

RUN export uid=1000 gid=1000 && \
    mkdir -p /home/developer && \
    echo "developer:x:${uid}:${gid}:Developer,,,:/home/developer:/bin/bash" >> /etc/passwd && \
    echo "developer:x:${uid}:" >> /etc/group && \
    echo "developer ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/developer && \
    chmod 0440 /etc/sudoers.d/developer && \
    chown ${uid}:${gid} -R /home/developer

COPY coffee.swf /home/developer/coffee.swf
USER developer
ENV HOME /home/developer
CMD /usr/bin/gnash /home/developer/coffee.swf

You must replace uid=1000/gid=1000 with your user / group id, which you can find via the id command, example output:

$ id
uid=1000(remy) gid=1000(remy) groups=1000(remy)

In my case, I have a .swf file I need to run, which is included in the Docker image via the COPY step and provided to gnash with the CMD step.

The base container image is the default Ubuntu 18.04 image, in which gnash is installed, as well as sudo. Sudo and the user creation are required for x11 forwarding.

Build the docker container:

docker build -t gnash .

When it's finished building, you can run it with the following command:

docker run -ti --rm -e DISPLAY=$DISPLAY --net=host -v /tmp/.X11-unix:/tmp/.X11-unix gnash

-e DISPLAY=$DISPLAY and -v /tmp/.X11-unix:/tmp/.X11-unix share your local x11 socket and display with the container, required for x11 forwarding.

--net=host is required for me due to the software automatically connecting to a port on localhost (which I forward via SSH to an actual development board). You could omit that if your use case is different.

If you need a specific /etc/gnashrc file in your container, you must add the file to this folder (with the Dockerfile) and add a copy step in the Dockerfile:

COPY gnashrc /etc/gnashrc

If you make changes to the Dockerfile, you must build the container again:

docker build -t gnash .

That's all there is to it to run 9 year old software on a recent version of Ubuntu.

Tags: debian , docker , dpkg , flash , gnash , linux , tutorials , ubuntu , x11