Skip to content

Instantly share code, notes, and snippets.

@grahamwhaley
Last active July 10, 2020 15:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save grahamwhaley/907dce0957036f16cfa7513160d261ec to your computer and use it in GitHub Desktop.
Save grahamwhaley/907dce0957036f16cfa7513160d261ec to your computer and use it in GitHub Desktop.
nanovna-saver under Docker on Linux

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.

Build the image

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" .

To run it

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!:

nanovna-saver running

git repo

I pushed those files up into a user fork/branch on github for posterity - you can find them in my 20200710_run_docker branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment