HamRig Gateway 3 in Docker ========================== For Linux on x86-64 and on 64-bit ARM - a Raspberry Pi 3, 4 or 5 with the 64-bit Raspberry Pi OS, a mini PC, a home server. The container runs the official HamRig Gateway 3 release (the same program as the ZIP from https://hamrig.com/download.html), with the radio's USB serial port and USB sound card passed in. Files (https://hamrig.com/assets/gateway-docker/): hamrig-gateway-docker.sh helper: install, update, start, stop, status, logs, backup, restore, import-native, remove compose.yaml the container: host network, devices, data volume Dockerfile the image: downloads and checks the release README.txt this file Not for Windows or macOS: Docker Desktop has no host network and no USB devices. Use the normal Windows download there. 1. Quick start -------------- Needs Docker 23 or newer with the compose and buildx plugins (Docker's install script below brings both). Download the helper, read it, run it: curl -fsSLO https://hamrig.com/assets/gateway-docker/hamrig-gateway-docker.sh less hamrig-gateway-docker.sh sh hamrig-gateway-docker.sh install The helper checks the system (64-bit, Docker, compose, buildx), shows what it will do and asks. Then it creates ~/hamrig-gateway with compose.yaml, Dockerfile and a .env with this machine's values (time zone, the group numbers of dialout/audio/plugdev), builds the image and starts the container. It prints the addresses of the web UI at the end. The folder is the gateway's alone: the helper does not use a home folder or a folder with other files in it (--dir FOLDER picks another one; give it to every later command as well). Not in the docker group yet? Run the helper with sudo - it still uses your home folder; then use sudo for the later commands, too. HamRig Gateway 3 already runs on this machine without Docker (as the service hamrig-gateway3)? The helper sees it and offers to stop it - two gateways cannot share the ports and the radio. Its gateway ID, pairing and devices can be taken over: see 7. Without the helper, the same by hand: mkdir ~/hamrig-gateway && cd ~/hamrig-gateway curl -fsSLO https://hamrig.com/assets/gateway-docker/Dockerfile curl -fsSLO https://hamrig.com/assets/gateway-docker/compose.yaml docker compose up -d --build The helper can take over such a folder later. As it did not put the files there, it cannot tell whether you changed them: "update" asks before it replaces one (yours is kept as .old); with -y it keeps yours and saves the new one next to it as .new. No Docker yet? Docker's install script, also download - read - run: curl -fsSL https://get.docker.com -o get-docker.sh less get-docker.sh sudo sh get-docker.sh sudo usermod -aG docker "$USER" (log out and in again) 2. Pairing and the web UI ------------------------- On the machine itself: http://localhost:8770 From another computer: https://:8771 The https address uses a self-signed certificate; the browser asks once. The password login from another computer needs the https address. A new gateway shows a setup page to every computer on the local network until it is paired: pair it there with a code you confirm on hamrig.com, or with your HamRig login. On the machine itself (localhost) you are the owner without a login. Pairing on the command line instead: cd ~/hamrig-gateway docker compose exec gateway hamrig-gateway3 pair --code If you do not want the network setup page (another person on the network could pair a new gateway before you): add "--no-setup-window" to the command line in compose.yaml (command: ["--no-setup-window"]) and pair on the command line or from the machine itself. After pairing, add the radio in the web UI: Devices - Add device - Radio - "Search for radios". Switch the radio on and connect it by USB first. 3. Everyday use --------------- sh hamrig-gateway-docker.sh status container, health, version, addresses sh hamrig-gateway-docker.sh logs container log (warnings and errors) sh hamrig-gateway-docker.sh logs --full the gateway's complete log sh hamrig-gateway-docker.sh stop stop (radios go to receive first) sh hamrig-gateway-docker.sh start sh hamrig-gateway-docker.sh update newest release (see 4.) sh hamrig-gateway-docker.sh backup save the gateway's data (see 6.) The container starts again by itself after a reboot until you stop it. Plain docker compose works as well: cd ~/hamrig-gateway; docker compose ps, logs -f, stop, up -d. 4. Updates ---------- The gateway does not update itself in the container: its program folder is read-only, and the System page says so when a new version is available. Update the image instead: sh hamrig-gateway-docker.sh update That fetches the newest compose.yaml/Dockerfile (a file you edited is kept; the new one is saved next to it as .new), rebuilds the image with the newest release and a fresh Debian base, and recreates the container. The data volume stays. By hand: docker compose build --pull --build-arg GW_CACHEBUST=$(date +%s) docker compose up -d Other release or channel - in .env: GW_VERSION=3.0.1 exactly this version (empty = the newest) GW_CHANNEL=beta previews (default stable) then rebuild as above. Do not pin an older version than 3.0.1 for an IC-705, IC-905 or IC-9700: 3.0.0 cannot pick the radio's CI-V port of its two serial ports ("matches 2 devices; add if="). 5. What the files do, and why ----------------------------- Image (Dockerfile): - Debian 12 slim. The release ZIP for the CPU (x64 or arm64) comes from hamrig.com over HTTPS; its SHA-256 must match the release list or the build stops. The list and the ZIP come from the same server: the check catches a download damaged or swapped on the way, it does not make the image more trustworthy than hamrig.com itself (like the gateway's own updater; there is no signature yet). - The gateway runs as user "hamrig" with uid/gid 8770 - not as root, and not as your own user: a number that owns nothing on the host. - No setuid programs (su, mount, passwd ...) in the image. - jt9 from Debian's WSJT-X package for the FT8/FT4 decoder (WITH_JT9=0 in .env leaves it out: about 70 MB smaller, no FT8 decoding). - Data in /data (configuration, pairing, certificates, logs). - At every start the entrypoint removes what a hard stop (power cut, docker kill) left in /tmp: the programs unpack 60-280 MB there. Container (compose.yaml): - network_mode: host - the gateway uses the machine's own network, as a normal installation does; mDNS (hamrig-gateway.local), WebRTC audio and the web UI's check of its own addresses need that. The gateway uses ports 8770 and 8771 of the machine. Other ports: command: ["--port", "8780", "--tls-port", "8781"] - cap_drop ALL and no-new-privileges: the gateway needs no privileges, and nothing in the container can gain any. - /dev is shared READ-ONLY: device files open normally, but nothing in /dev can be created or changed. device_cgroup_rules allow serial ports (ttyUSB, ttyACM), sound cards (/dev/snd) and USB/HID relay boards on top of what every container may open (null, zero, random, tty, pts); the file permissions still decide (dialout, audio, plugdev). /dev is shared as a whole, not as single devices, so that the device file of a radio switched on later shows up in the container too, and the stable names in /dev/serial/by-id exist there. The container gets its own /dev/shm and /dev/mqueue (the host's are writable for everyone; Docker before 25 makes only /dev itself read-only, not what is mounted inside it). - group_add gives the container the host's dialout/audio/plugdev groups. - stop_grace_period 20 s: on "stop" the gateway sets the radios to receive and ends its device processes (at most about 15 s). - Data volume hamrig-gateway_hamrig-gateway-data. "docker compose down" keeps it; "docker compose down -v" DELETES it (pairing, devices, logs). .env (written by the helper, used for building and running): TZ=Europe/Berlin time zone DIALOUT_GID=20 group number of the serial ports (ls -ln /dev/ttyUSB0) AUDIO_GID=29 group number of the sound devices (ls -ln /dev/snd) PLUGDEV_GID=46 USB/HID devices with plugdev udev rules HIDRAW_MAJOR=... /dev/hidraw* number (grep hidraw /proc/devices); the kernel picks it at boot, so the helper writes it anew on every install, update and start GW_CHANNEL=stable WITH_JT9=1 optional: HAMRIG_UID=8770 user/group in the container (default 8770) HAMRIG_GID=8770 GW_VERSION, GW_ZIP, GW_SHA256, GW_ALLOW_UNVERIFIED see 4. and 9. After changing a value: docker compose up -d --build 6. Backup, restore, remove -------------------------- The data volume holds the gateway's identity: its gateway ID, the pairing with your account, the devices, certificates and logs. Without it a new gateway has to be paired and set up again. Save it: sh hamrig-gateway-docker.sh backup ~/hamrig-gateway-backup-