I'm a Solus user (and enthusiast), but as one I also faced a common problem. Not every desktop app is available on Solus Linux and you also can't run
.rpm installation files, because Solus uses a different package manager and isn't based on any other Linux distribution.
But my study required me to install an application called "Inform 7". This software is available for Ubuntu, Debian and also Fedora. If you have neither of these, you need to compile it by yourself.
That's what I first tried, but after hours of trying and getting a headache, I came to the conclusion it isn't possible to compile this app on my laptop, because it needed a very old and deprecated library. I had to find another workaround.
One workaround was to get a virtual machine and run this app inside of this VM. But VMs are not the best solution in terms of memory usage and battery consumption. Just to run this little app, you need to run a whole Virtual Machine with at least 2 Gigabytes of memory.
One day, I got the idea, to use my Docker experience to run this app with Docker and I regret that I didn't get this idea earlier. I built myself a script, to first build a customized Docker image and then run it. It almost looks and feels like having it installed natively. And it also uses almost no extra memory.
Here's how to do it:
- You need Docker installed on your system and your user should be member of the
- You should use the X11 windows manager, because that is used to bridge the application to your system.
As example of this tutorial I use the programm gnome-inform7.
First, there's the
build.sh script, which first downloads the
deb file and then starts the Docker build.
#!/bin/bash URL=http://inform7.com/download/content/6M62/gnome-inform7_6M62-1_amd64.deb wget $URL -O inform.deb docker build . -t inform --build-arg informuser=$USER echo "Successfully build Inform 7 image. Now you can start it by typing ./run.sh"
The script downloads the
deb file with
wget to the specified file name and then builds the Docker image and tags it accordingly. It also passes the username, which the Docker image should use. This is helpful, because this way your home folder can be mounted to the container and you can save files to the home folder, which will persist. All other files (outside your home folder) will be deleted after stopping the container.
Second, there's the
Dockerfile, which instructs Docker how to build the image:
FROM debian:9-slim COPY inform.deb /tmp ARG informuser RUN apt-get update && dpkg -i /tmp/inform.deb || true RUN apt-get install -y -f --no-install-recommends && rm -rf /var/lib/apt/lists/* && useradd $informuser USER $informuser ENV HOME /home/$informuser CMD /usr/bin/gnome-inform7
It is based on Debian 9 slim version, because that's the smallest image I found, which can install
deb files. It first copies the downloaded installation file and then installs it. After doing that, it also adds a user with the same username as you are using to execute this build. And it specifies to run the program when starting the container.
Last, but not least, there's the
run.sh script, which starts the container. That's the one you need to run to start the app:
#!/bin/bash echo "Your local home folder is bind to /home/$USER" docker run --rm -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix -v $HOME:$HOME --name inform inform
It just calls the Docker run command whith connecting the X11 windows manager from the host with the container X11 window manager and also mounting your home folder. When you close the application, the container get's removed. So don't forget to save your files in your home folder before doing so!
You can find the whole example on GitHub.
If you want, you can also add the
run.sh script to your application menu, so it's even easier to launch that application.
With that you should be able to run
deb based programs on almost any Linux (where you can install Docker and have the X11 window manager).
If you want to run a program, which is already available in the Debian packages, you can replace the install command to install the package directly. For that you can find an example in this GitHub repository.
Subscribe to Dev All The Things
Get the latest posts delivered right to your inbox