HomelabServices and mediaguide
Docker networking patterns for the arr stack
Two Docker Compose patterns for running Sonarr, Radarr, and related services on a Linux NAS (network-attached storage). The first solves a routing problem: how to give containers first-class LAN (local area network) IPs (Internet Protocol addresses) so an edge reverse proxy on a different host can reach them without hairpin NAT (network address translation). The second solves a migration problem: how to move arr databases between filesystems (Unraid’s FUSE (Filesystem in Userspace) to ZFS (Zettabyte File System)) without corrupting every stored path.
Pattern 1: Dual-homed macvlan containers
Section titled “Pattern 1: Dual-homed macvlan containers”The problem
Section titled “The problem”The edge Caddy reverse proxy runs on a separate host (an MS-01 router). The Docker compose stack runs on a NAS. If you proxy to Docker bridge IPs (172.19.1.x:8989), the router needs a route to that subnet - and the bridge subnet is not routable by default.
The common fix is publishing ports on the Docker host (ports: "8989:8989") and proxying to 192.168.22.2:8989. This works but couples the proxy to the host IP and consumes host ports.
The pattern
Section titled “The pattern”Give each container a macvlan interface with a first-class LAN IP, alongside its existing Docker bridge IP on the compose network. The bridge IP handles east-west traffic between containers. The LAN IP handles north-south traffic from the edge proxy.
XikeStor switch (VLAN 60) │ ┌───────────────┼───────────────┐ │ │ │ MS-01 router servarr NAS other hosts (edge Caddy) 192.168.22.2 │ │ │ proxied to LAN macvlan IPs ├──── 192.168.22.22 radarr ├──── 192.168.22.23 sonarr ├──── 192.168.22.24 bazarr └──── ...The macvlan parent interface is the host’s physical NIC (network interface controller). Each container’s macvlan interface gets a MAC (media access control) address derived from its LAN IP octet: 02:42:c0:a8:16:<octet-hex>.
Compose block
Section titled “Compose block”services: sonarr: image: lscr.io/linuxserver/sonarr:latest networks: servarr: # east-west: Docker bridge ipv4_address: 172.19.1.3 lan: # north-south: macvlan ipv4_address: 192.168.22.23 mac_address: "02:42:c0:a8:16:17" gw_priority: 100 # ... rest of service config
networks: servarr: driver: bridge ipam: config: - subnet: 172.19.1.0/24 lan: driver: macvlan driver_opts: parent: enp36s0f1 # host's physical NIC macvlan_mode: bridge ipam: config: - subnet: 192.168.22.0/24 gateway: 192.168.22.1On the lan attachment:
-
gw_priority: 100on thelan(macvlan) attachment. Docker picks the attachment with the highestgw_priorityas the default gateway, so this makes the LAN the default route: internet egress leaves via the edge router as a LAN address instead of being NAT’d through the Docker bridge and host. -
Pinned MAC addresses: predictable MACs prevent ARP (Address Resolution Protocol) table churn when containers restart. The pattern maps the LAN IP’s last octet to the MAC’s last octet:
02:42:c0:a8:16:<hex>. For192.168.22.23, the last octet is 23 (0x17), so the MAC is02:42:c0:a8:16:17.
Caddy proxy block
Section titled “Caddy proxy block”The edge Caddy proxies directly to LAN IPs - no Docker host port publishing, no NAT:
sonarr.example.com { import waf_off import tls_config_rfc2136 encode zstd gzip reverse_proxy 192.168.22.23:8989 { import proxy_headers } import site_log sonarr}IP allocation
Section titled “IP allocation”Reserve a contiguous block of LAN IPs for the macvlan containers. On this stack, bridge IP 172.19.1.X maps to LAN IP 192.168.22.(X+20):
| Service | Bridge IP | LAN IP |
|---|---|---|
| radarr | 172.19.1.2 | 192.168.22.22 |
| sonarr | 172.19.1.3 | 192.168.22.23 |
| bazarr | 172.19.1.4 | 192.168.22.24 |
| prowlarr | 172.19.1.10 | 192.168.22.30 |
| jellyfin | 172.19.1.15 | 192.168.22.35 |
| sabnzbd | 172.19.1.19 | 192.168.22.39 |
| seerr | 172.19.1.21 | 192.168.22.41 |
Services behind VPN (virtual private network) containers (qbittorrentvpn; slskd until it was replaced on 2026-09-30) are not dual-homed - they use network_mode: service:X and have no macvlan of their own. Expose their web UIs (user interfaces) via host-published ports instead.
Macvlan hairpin constraint
Section titled “Macvlan hairpin constraint”Macvlan interfaces on the same parent interface cannot reach each other by default. Traffic between 192.168.22.22 and 192.168.22.23 must go through the switch even though they share the same physical NIC. If containers need to talk to each other on the LAN subnet, use their bridge IPs instead - east-west traffic stays on the Docker bridge.
Verification
Section titled “Verification”For each dual-homed container:
- Bridge path:
docker exec sonarr curl -sf http://172.19.1.3:8989/ping - LAN path from a different host:
curl -sf http://192.168.22.23:8989/ping - Default route:
docker exec sonarr ip route | grep defaultshould show the bridge gateway - Edge proxy:
curl -sI https://sonarr.example.com | head -1
Pattern 2: Arr database migration across filesystems
Section titled “Pattern 2: Arr database migration across filesystems”The problem
Section titled “The problem”Arr databases (SQLite) store absolute paths for every series, movie, root folder, and import list entry. Moving from one filesystem to another invalidates every stored path.
The specific migration here was Unraid (shfs/FUSE) to NixOS (ZFS), but the pattern applies to any filesystem change: ext4 to ZFS, a mount point rename, moving from one NAS to another.
Before migration: path audit
Section titled “Before migration: path audit”Map every path that changed. On the old host, the arr stack used:
| What | Old path | New path |
|---|---|---|
| Media library (tv, movies) | /mnt/user/data/servarr/media -> /data/media/... | /tank/media -> /data/... |
| Configs/DBs | /mnt/user/data/<svc>/config | /rpool/cache/data/<svc>/config |
| Usenet incomplete | /mnt/cache/data/servarr | /scratch/downloads/usenet/incomplete |
| Transient downloads | /mnt/cache/slskd-dl/ | /scratch/slskd-dl/ (kept by slskarr) |
The TRaSH container-path convention also changed: previously Sonarr mounted /mnt/user/data/servarr:/data (root folders at /data/media/tv); new layout mounts /tank/media:/data (root folders at /data/tv). The DB (database) stores the container path, not the host path.
The SQLite rewrite script
Section titled “The SQLite rewrite script”A script on the new host rewrites paths inside the SQLite databases before the stack starts:
#!/bin/bash# /root/arr-path-migrate.sh - run on the new host before compose upset -euo pipefail
DB_DIR="/rpool/cache/data"
# Sonarr: Rewrite root folders + series pathsif [ -f "$DB_DIR/sonarr/config/sonarr.db" ]; then cp "$DB_DIR/sonarr/config/sonarr.db" "$DB_DIR/sonarr/config/sonarr.db.pre-migrate" sqlite3 "$DB_DIR/sonarr/config/sonarr.db" <<'SQL' UPDATE RootFolders SET Path = REPLACE(Path, '/data/media/tv', '/data/tv'); UPDATE Series SET Path = REPLACE(Path, '/data/media/tv', '/data/tv'); UPDATE ImportLists SET RootFolderPath = REPLACE(RootFolderPath, '/data/media/tv', '/data/tv');SQLfi
# Radarr: Rewrite root folders + movie paths + collection pathsif [ -f "$DB_DIR/radarr/config/radarr.db" ]; then cp "$DB_DIR/radarr/config/radarr.db" "$DB_DIR/radarr/config/radarr.db.pre-migrate" sqlite3 "$DB_DIR/radarr/config/radarr.db" <<'SQL' UPDATE RootFolders SET Path = REPLACE(Path, '/data/media/movies', '/data/movies'); UPDATE Movies SET Path = REPLACE(Path, '/data/media/movies', '/data/movies'); UPDATE Collections SET RootFolderPath = REPLACE(RootFolderPath, '/data/media/movies', '/data/movies'); UPDATE ImportLists SET RootFolderPath = REPLACE(RootFolderPath, '/data/media/movies', '/data/movies');SQLfi- Self-backing-up: copies the DB before mutating it (
*.pre-migrate) - Idempotent:
REPLACE(Path, old, new)is a no-op on already-migrated paths - Run before stack starts: databases must not be open when rewritten
Path-consistency rule
Section titled “Path-consistency rule”Arr-coupled consumers that read paths from the Sonarr/Radarr API (application programming interface) must mount the same /data as the arr themselves. If Sonarr reports a series at /data/tv/Show Name and bazarr mounts /tank/media:/data/media, bazarr looks for /data/media/tv/Show Name and finds nothing.
On this migration, the rule was: Sonarr, Radarr, Lidarr, SABnzbd all mount /tank/media:/data. Arr-coupled consumers (bazarr, decluttarr) mount the same /data. The exception is Jellyfin, which stores library paths in its own database and kept its existing /data/media mount unchanged. (Jellyfin on this box also hosts watch parties through lockstep, whose session server is one more container on the same network.)
Three-tier storage layout (ZFS)
Section titled “Three-tier storage layout (ZFS)”The tiered design generalises beyond ZFS.
| Tier | Pool | What lives there |
|---|---|---|
| Hot | NVMe (Non-Volatile Memory Express) (rpool) | Container configs, SQLite DBs, Jellyfin metadata |
| Bulk | HDD (hard disk drive) raidz2 (tank) | Media library, personal data, daily backups |
| Scratch | NVMe (scratch) | Usenet incomplete/par2/unrar, download staging. sync=disabled for write throughput |
The hot tier holds everything that needs low latency (UI responsiveness depends on SQLite read speed), the bulk tier holds large immutable files, and scratch holds transient data that can be downloaded again, so it is fast and non-redundant.
Hardlinks only work within a single ZFS dataset. The media library and download directories live in the same tank/media dataset so arr importers can hardlink instead of copying.
Verification
Section titled “Verification”After migration and stack bring-up:
- Sonarr:
curl -sH "X-Api-Key: $KEY" https://sonarr.example.com/api/v3/series | jq '[.[] | .path] | .[0:3]'- verify paths show/data/tv/... - Radarr: same check with
/api/v3/movie - Health: all containers show
healthyviadocker ps - Queue: queue is empty (no residual path errors from the old filesystem)
- Import test: manually trigger a download and verify import completes without path errors
Gotchas and lessons learned
Section titled “Gotchas and lessons learned”-
Macvlan containers cannot reach each other on the macvlan network. Use bridge IPs for container-to-container traffic.
-
Without
gw_prioritythe default route is not chosen explicitly. Docker gives the default gateway to the attachment with the highestgw_priority(default 0). Setgw_priority: 100on thelanattachment so the macvlan gateway wins. -
network_mode: service:Xcontainers have no macvlan interface. They share the VPN container’s netns, which may or may not have a macvlan. Publish their web UIs via host ports instead. -
Arr databases store container paths, not host paths. The rewrite fixes paths as the container sees them (
/data/tv, not/tank/media/tv). Test the script on a copy of the database before running against the live file. -
Match the full old prefix in
REPLACE.REPLACE(Path, '/data/media', '/data')would break paths that already have the new format. Include the extra component (/data/media/tv). -
Run the rewrite before the stack starts. SQLite databases will be open if any arr container is running. Stop the stack, run the script, then start.
-
ZFS datasets are separate filesystems. Hardlinks only work within one dataset. Keep media and download staging in the same dataset, or every import becomes a full copy.
*arr API gotchas and the arr CLI commands
Section titled “*arr API gotchas and the arr CLI commands”Each API behaviour below was discovered during the 2026-09-01 media merge and is encoded as a named command in <arr-cli>, a Go binary that runs inside the app’s network namespace over docker run --network container:sonarr.
Three bugs that became commands
Section titled “Three bugs that became commands”ManualImport seriesId nesting. The ManualImport command payload places seriesId and episodeIds at the TOP level of each file object, not inside the nested series object. Getting this wrong produces a command that completes "completed" and imports zero files - silently. This was hit on 31+ import operations before the pattern was understood. The arr CLI (command-line interface)‘s import builds the payload correctly (files[].seriesId + files[].episodeIds for Sonarr, files[].movieId with no episodes for Radarr) and refuses to report success when it pushed files and the tracked count did not move while importable files remain.
Sonarr 4.0.19 audiocodec token render bug. A single-character transcription error - {[Mediainfo AudioCodec]{ Mediainfo AudioChannels]} instead of TRaSH’s }{ (the closing bracket inside the group was a ] not a }) - caused Sonarr 4.0.19 to emit the literal text {[Mediainfo AudioCodec 2.0]} into filenames. An earlier restore run reintroduced the bad format and wrote it into 234 filenames (Astro Boy 193, Barry 41). The corrected TRaSH template renders [DTS 5.1] cleanly on Sonarr 4.0.19 and Radarr 6.3. The arr CLI’s naming set validates by apply-and-verify: it PUTs each candidate, reads the server-rendered examples, and accepts only when no sample contains residual {[ or ]} fragments.
RefreshSeries does not import existing files. Calling POST /command RefreshSeries over a series with files on disk fetches metadata but imports nothing. Import-existing is a separate flow: GET /manualimport?seriesId= (preview) -> POST /command ManualImport{files} (assign) -> POST /command RenameSeries (apply the naming config). The arr CLI’s ImportExisting encodes this as one command, including a wait for the post-add metadata refresh to reach a terminal state - on Attack on Titan’s 88 files the refresh ran 37 seconds and episode rows appeared after 2 seconds, but all files still previewed as zero-episode until it finished.
TRaSH naming: apply-and-verify
Section titled “TRaSH naming: apply-and-verify”The arr CLI’s naming set applies the TRaSH profile for the running app version. The format carries quality, custom formats, audio codec, audio channels, video dynamic range, video codec, and release group, in that order. For Sonarr 4.x the corrected two-group audiocodec template ({[Mediainfo AudioCodec}{ Mediainfo AudioChannels]}) renders [DTS 5.1]; a split-group fallback ({[Mediainfo AudioCodec]}{[Mediainfo AudioChannels]}) rendering [DTS][5.1] is kept as candidate 2. Radarr 6.3+ renders the TRaSH verbatim template cleanly on its first attempt.
The apply-and-verify path exists because Sonarr 4.0.19’s examples endpoint cannot preview a query-supplied format - the [FromQuery] binding drops string format parameters and only binds Id. So naming set PUTs the candidate, reads the live render, checks for residual braces, and restores the original if dirty. A naming probe command renders an explicit format through the same path, net-zero (it restores the original after the probe). The residual check flags unrendered TOKENS only ({[, ]} or a brace span with a token word), not deliberate braces: TRaSH’s jellyfin movie format uses {{Edition Tags}} so the output legitimately reads {Ultimate Extended Edition}.
Indexer restore: forceSave and the Prowlarr fullSync gap
Section titled “Indexer restore: forceSave and the Prowlarr fullSync gap”?forceSave=true bypasses the connectivity test. An earlier note claimed the opposite, but that conclusion came from a probe run while Prowlarr was stopped - the 400 carried a 502 BadGateway network failure, not a validation refusal. With Prowlarr up and the real key injected, POST /indexer?forceSave=true returns 201. The entire -skip indexer restore strategy was built on this false premise.
Prowlarr’s fullSync alone recovers only 7 of 13 indexers. The app runs an empty-term category search at indexer-add time and refuses on no results (RadarrV3Proxy: No Results in configured categories), which Prowlarr cannot force past. Restoring from the export instead recovered 10 of 12 per app. All 12 Prowlarr-managed indexers share the SAME apiKey (Prowlarr’s own, read from prowlarr/config.xml), so the arr CLI supplies it endpoint-wide as ARRCLI_SECRET_INDEXER__APIKEY (the item segment is omitted; a per-item key still wins where set). The production restore invocation: restore -app X -in DIR -skip downloadclient/NZBGet -skip downloadclient/Rustnzb -prune, with the indexer key plus the SAB (SABnzbd) apiKey and qBittorrent password in the environment.
Masked-secrets export trap
Section titled “Masked-secrets export trap”The *arrs redact every secret field value on GET - indexer apiKeys and download client passwords all come back as ********. An export therefore captures placeholders, and restoring one recreates the item with a credential that authenticates against nothing (proven live: POSTing an exported indexer with its masked value returns 401 Unauthorized). On this stack, 12 indexer fields and 3 download client fields were masked on export.
The arr CLI’s export scans for masked fields and writes a sidecar file (<app>-MASKED-SECRETS.txt) naming the env key for each. restore reads real values from the ENVIRONMENT, never from argv or a file - the shape secretctl is designed for: ARRCLI_SECRET_<ENDPOINT>_<ITEM>_<FIELD>, with non-alphanumerics collapsed to _. An item whose secret cannot be resolved is NOT created (-allow-masked overrides). Creating it would look configured and fail every auth.
Trim workflow: rating, corpus matching, and import exclusions
Section titled “Trim workflow: rating, corpus matching, and import exclusions”The trim commands encode the rating-based want-list cleanup that took Radarr from 2,126 movies to 1,338 (about 5 TB). The flow is catalog export -> rating join -> candidate manifest -> review -> bulk delete with import exclusion:
<arr-cli> owner export -app radarr -out /work/owners<arr-cli> rating join -in /work/owners/owners.json -ratings ratings.csv \ -imdb-col 7 -rating-col 0 -out /work/rated<arr-cli> trim list -app radarr -in /work/rated/owners.json -below 70 \ -corpus criterion.txt -actor chow-titles.json -out /work/trim# REVIEW /work/trim/manifest.md<arr-cli> trim delete -app radarr -in /work/trim/manifest.json -files -exclude -executeCorpus matching uses word-boundary normalised title matching with Latin accent folding (an owner’s title, original title and alternate titles are checked against corpus lines). Accent folding maps accented characters to their ASCII (American Standard Code for Information Interchange) base - “Andre” matches “André”, and “Cos” from “Coś” does NOT substring-match “costa-gavras” because the match is word-bounded. Short 1-2 character ASCII titles are skipped as too generic; short non-ASCII titles (8½) are specific enough to match. Years must agree within 1. Actor matching is exact normalised title match, not substring - the live run produced a Metropolis/大都會 false positive from substring matching before exact match was adopted.
Import exclusion. trim delete -exclude sets the app-specific exclusion field after delete (Radarr addImportExclusion, Sonarr addImportListExclusion), so the *arr does not re-add the entry via import lists. The editor body matches the *arr UI’s bulk delete exactly: movieIds/seriesIds + deleteFiles + the exclusion flag, with no minimumAvailability field. The command is apply-verify: it re-fetches current ids, applies only to those still present in batches of 150, then confirms each id is gone.
File reference
Section titled “File reference”| Path or object | What it is |
|---|---|
| The stack’s compose file | The services: and networks: blocks in Pattern 1: macvlan attachments, gw_priority, the pinned MACs, and the servarr (bridge) and lan (macvlan) network definitions |
| The edge Caddyfile | The site block that reverse-proxies to the LAN macvlan IPs, no host port publishing |
/root/arr-path-migrate.sh | The SQLite path rewrite script, run on the new host before docker compose up |
/rpool/cache/data/<svc>/config/<svc>.db | The arr databases the script rewrites (sonarr.db, radarr.db) |
/rpool/cache/data/<svc>/config/<svc>.db.pre-migrate | The self-backup each rewrite leaves beside the database |
/tank/media and the download directory in the same dataset | The hardlink-preserving layout: media and downloads share one dataset |
/data/tv, /data/movies | The container-side paths the databases store, which is what the rewrite targets |
172.19.1.0/24 and 192.168.22.0/24 | The bridge and macvlan subnets; the LAN block is reserved for the dual-homed containers |
Related docs
Section titled “Related docs”- Docker Servarr stack security - hardening the arr stack, including network segmentation and filesystem isolation
- slskd behind WireGuard VPN with port-forward sync - dual VPN tunnel pattern for P2P (peer-to-peer) clients (superseded here by slskarr)
- slskarr: one process for Soulseek, the PIA (Private Internet Access) tunnel, and the Lidarr import - the single-process replacement for that trio, and the ownership and import guards it needs to run as root
- Migrating a NAS without losing a byte - the bulk-data migration that moved everything onto ZFS