Hello everyone,
After being in contact with Nestoras, I was asked to contribute to the forum so others can learn from the shared knowledge gained.
I have been trying to get gnuradio-companion working from within docker, primarily because I found manual installation of a compiled from source version together with several Oot-Of-Tree (OOT) modules cumbersome and sometimes tricky. Many of these compilation complexities stem from non-standard import paths for headers, libraries, cmake and pkg-config configuration files. While I am sure there are ways to make it work with Conda or Spack etc I found that just installing everything in docker can be very convenient. With this lengthy introduction out of the way, the actual steps are pretty straightforward. These shown steps are specifically for Wayland in this case.
docker run -it \
-e XDG_RUNTIME_DIR=/tmp \
-e WAYLAND_DISPLAY=$WAYLAND_DISPLAY \
-e QT_QPA_PLATFORM=wayland \
-v $XDG_RUNTIME_DIR/$WAYLAND_DISPLAY:/tmp/$WAYLAND_DISPLAY \
librespace/gnuradio /bin/bash
Then simply install dbus and gtk:
apt update apt install dbus-x11 gir1.2-gtk-3.0
You can now start gnuradio-companion
gnuradio-companion
Some limitations, GPU acceleration and audio wonât work as of yet in this container.
I tried getting pulseaudio working by adding the follow parameters to âdocker runâ.
--device /dev/dri
âdevice /dev/snd
-e PULSE_SERVER=unix:/run/user/$(id -u)/pulse/native
-v /run/user/$(id -u)/pulse/native:/run/user/root/pulse/native
-v ~/.config/pulse/cookie:/root/.config/pulse/cookie \
You need to install some additional packages using
apt install libpulse0 pulseaudio-utils alsaplayer-alsa alsa-utils
Unfortunately, gnuradio canât seem to find the pulse devices, I think this is because we are only passing pulseaudio to the container not alsa. And as far as I know Gnuradio uses alsa to lookup the pulse / pipewire devices. So you get the error âunknown PCM alsaâ. When you instead try to play a sound using the âaplayâ utility it works fine, so pulse is actually working in the container.
One last thing, you might notice everything runs as root in the container. This is because its quite some extra steps to get it working with your own userid inside the container. You need both a custom Dockerfile and an entrypoint I have includded them hidden below.
Dockerfile
ARG DEBIAN_IMAGE_TAG=librespace/gnuradio
FROM ${DEBIAN_IMAGE_TAG}
RUN apt update && apt install -y dbus-x11 gir1.2-gtk-3.0 libpulse0 pulseaudio-utils gosu alsaplayer-alsa alsa-utils
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
RUN chmod +x /usr/local/bin/entrypoint.sh
ENTRYPOINT [â/usr/local/bin/entrypoint.shâ]
CMD [âgnuradio-companionâ]
Entrypoint.sh
#!/bin/bash
# Configuration
USER_ID=${USER_ID:-1000}
GROUP_ID=${GROUP_ID:-1000}
USER_NAME=${USER_NAME:-dockeruser}
echo "Configuring container for UID: $USER_ID and GID: $GROUP_ID..."
if ! getent group $GROUP_ID > /dev/null; then
groupadd -g $GROUP_ID $USER_NAME
fi
if ! getent passwd $USER_ID > /dev/null; then
useradd -u $USER_ID -g $GROUP_ID -m -s /bin/bash $USER_NAME
else
# If user exists, ensure home dir
USER_NAME=$(getent passwd $USER_ID | cut -d: -f1)
mkdir -p /home/$USER_NAME
fi
# Set permissions
chown -R $USER_ID:$GROUP_ID /home/$USER_NAME
# Set pulseaudio cookie
mkdir -p /home/$USER_NAME/.config/pulse
chown -R $USER_ID:$GROUP_ID /home/$USER_NAME/.config/pulse
echo "Switching to user $USER_NAME..."
# Run application with gosu
exec gosu $USER_NAME "$@"
Extended docker run command (still no sound in gnuradio)
docker run -it \
âdevice /dev/dri \
âdevice /dev/snd \
-e USER_ID=$(id -u) \
-e GROUP_ID=$(id -g) \
-e XDG_RUNTIME_DIR=/tmp \
-e WAYLAND_DISPLAY=$WAYLAND_DISPLAY \
-e QT_QPA_PLATFORM=wayland \
-e PULSE_SERVER=unix:/run/user/$(id -u)/pulse/native \
-v $XDG_RUNTIME_DIR/$WAYLAND_DISPLAY:/tmp/$WAYLAND_DISPLAY \
-v /run/user/$(id -u)/pulse/native:/run/user/$(id -u)/pulse/native \
-v ~/.config/pulse/cookie:/home/dockeruser/.config/pulse/cookie \
librespace/gnuradio /bin/bash
I hope this is somehow vaguely interesting or useful to you. Took more time to put on paper then I thought.
Kind regards,
Corne (Dantali0n)