Plex media server on two NAS boxes
A Plex media server with its helpers, described in a few Docker Compose files and kept up to date by a script that updates every day and puts the old version back if something breaks.
The idea
At home I have two small NAS boxes that mostly hold films and series: a TerraMaster and a UGREEN. On each of them runs the same stack: Plex, to browse and stream the library, and three helpers from the same family: Sonarr and Radarr, which keep series and films in order, and Prowlarr, which manages their sources. There’s no download client: the files get into the folders by hand, and the helpers only organize what is already there.
Everything is described in a few Docker Compose files, one per NAS. They’re short, but they need care: each box has its own folders, its own user and its own quirks.
Two boxes, two sets of quirks
- The TerraMaster runs everything as the administrator user, and every container shares the box’s network directly, without mapped ports. Its operating system hides surprises: SSH listens on a non-standard port, Docker isn’t on the path of non-interactive sessions, the Compose project has a name different from its folder (so a command run by hand creates a second, empty stack), and the folder that holds the scheduled tasks lives in memory and is rebuilt at each boot from a different file than the obvious one.
- The UGREEN uses an ordinary user for Plex and the helpers, and the media folders are given to Plex in read-only. Docker is reachable only as administrator. The hardware-transcoding section is commented out for now: it needs a paid Plex feature.
The files kept on the Mac are only copies; the live ones are on the NAS boxes. A thing worth remembering before changing anything.
Updates: the same idea as for the password manager
The images follow the “latest” label and Plex takes its updates from the container image, not from its internal updater. Doing it by hand means pulling the images and recreating the containers, boring enough to be forgotten for months. So I wrote a single script, shared by the two boxes:
- it pulls the new images;
- it recreates only the containers whose image changed;
- it waits ninety seconds and checks that each one is running and hasn’t restarted;
- if one isn’t, it puts the previous image back;
- only after a successful update does it remove the old images.
I didn’t use Watchtower, the classic tool for this: it is archived and breaks on newer versions of Docker. The script follows the one I already use for Vaultwarden, with the same rollback.
One detail changes the schedule: both NAS boxes are switched off at night. A job at three in the morning would never run, so it runs every day at half past five in the afternoon. The first run, on 31 October 2026, updated all four containers on each box without a hitch; on the UGREEN it also freed almost six gigabytes of old images.
What I learned
- A scheduled task isn’t “installed” until you’ve checked where the system really keeps it: on one box the obvious file is overwritten at every boot.
- Scripts run by the scheduler don’t see the same path as an interactive session; the script must say where Docker is.
- The script reads the Compose project name from the running containers instead of assuming it, which avoids the second-empty-stack trap above.
- After a firmware update of the NAS, check that the scheduled line is still there.
Status
Completed. The stack runs on both boxes and updates itself every day. Nothing else is planned: if something breaks, the log next to the script says where.
Stack
Plex · Sonarr · Radarr · Prowlarr · Docker Compose · shell script · cron