Running nanovna-saver under Docker
I have a nanovna, which I want to use with Linux. Great, probably
the best UI out there for the nanovna - nanovna-saver
supports use under Linux - it is a Python Qt based app....
So, I tried it on my Ubuntu 18.04 machine. Sigh, it requires Python v3.7, and afaict, that is a
royal pain to get working on 18.04 - well, it was for me anyway. I got stuff installed and linked
over etc., and could still not run nanovna-saver
locally... what to do?
One of my routes to cure such issues is to try and run things inside a docker image - that way you can easily isolate versions of components down to just what you need. OK, so, you bring in some other challenges. Let's see if they are surmountable...
What challenges?, well, off the top of my head:
- This is GUI app. Docker images don't normally have access to the host graphics
- And this is a USB device - again, by default, no access
- And, we want to store settings and probably export data - well, that is something that at least is pretty common in docker.
I had a quick play, and still struggled to get the app up. The main issue seemed be be getting the UI up. I had a surf, and came across this repo which showed how to get python QT5 UI up under Docker - and, it worked when I tried it....
Taking that and adapting it a little (to use a Phython3.7 base), and adding in some parts for the USB access and mounting a volume so we can load/store defaults etc., I ended up with the below.
The Dockerfile looks like:
FROM python:3.7-buster
# Inspired from https://github.com/jozo/docker-pyqt5
# Add user
RUN adduser --quiet --disabled-password qtuser
# Install Python 3, PyQt5
RUN apt-get update \
&& apt-get install -y \
python3-pyqt5
# This may not be necessary, now we volume mount it in.
COPY . nanovna-saver/
RUN \
pip3 install ./nanovna-saver
And to build it, run:
docker build --label "nanovnasaver" --tag "nanovnasaver" .
Plug in your nanovna
- mine turns up as /dev/ttyACM0
. Then run the below:
docker run -it \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-v $(pwd):/nanovna-saver \
-e DISPLAY=$DISPLAY \
-u qtuser:dialout \
--device=/dev/ttyACM0 \
nanovnasaver python3 /nanovna-saver/nanovna-saver.py
You should get the UI come up. Here is a screenshot running an analysis of my 2m band co-liner - hmm, looks like there might be some work needed to tune that into band!:
I pushed those files up into a user fork/branch on github for posterity - you can find them in my 20200710_run_docker branch.