Skip to content

c2theg/plex_ubuntu_containers

Repository files navigation

plex_ubuntu_containers

TL;DR

Clone the repo, run the host bootstrap, edit .env, then run the smart installer/updater:

git clone https://github.com/c2theg/plex_ubuntu_containers.git
cd plex_ubuntu_containers
sudo ./bootstrap-ubuntu-24.04.sh
cp -n .env.example .env
nano .env
./install_update.sh

After that, the server will:

  • install and run Plex, Sonarr, Radarr, and SABnzbd with Docker Compose
  • auto-update Ubuntu every Sunday at 3:00 AM
  • auto-update the media stack every Sunday at 3:30 AM
  • prune old config backups every Sunday at 3:45 AM
  • check service health every 15 minutes and restart/recreate services if needed
  • check disk usage daily at 2:15 AM
  • reboot at 2:00 AM once uptime reaches the configured threshold

What this repo is

Docker Compose based Plex, Sonarr, Radarr, and SABnzbd stack for Ubuntu Server 24.04.

This repo is designed for a low-touch home server:

  • keep config and media data outside the containers
  • pull newer images and recreate containers instead of upgrading inside them
  • back up app config before updates
  • prune old backups automatically
  • self-check service health and restart failed containers
  • watch disk usage and log warnings
  • install scheduled OS, container, and reboot maintenance jobs

Included files

  • compose.yml — container definitions
  • .env.example — environment variables and path template
  • .gitignore — excludes .env, local overrides, and temporary files
  • bootstrap-ubuntu-24.04.sh — one-time Ubuntu host prep
  • install_update.sh — easiest entrypoint, runs install or update automatically
  • manage-media-stack.sh — manual lifecycle commands
  • setup-cron.sh — idempotent cron installer
  • health-monitor.sh — host-side service health checks with auto-restart
  • disk-space-check.sh — disk usage monitor with optional email alerts
  • reboot-if-needed.sh — reboots only when uptime reaches the configured threshold

Fast setup

git clone https://github.com/c2theg/plex_ubuntu_containers.git
cd plex_ubuntu_containers
sudo ./bootstrap-ubuntu-24.04.sh
cp -n .env.example .env
nano .env
./install_update.sh

What each step does

  1. bootstrap-ubuntu-24.04.sh

    • installs Docker, Docker Compose plugin, cron, curl, and common dependencies
    • enables Docker and cron
    • creates .env from .env.example if missing
    • installs the recurring cron jobs
  2. Edit .env

    • set your host paths
    • optionally set PLEX_CLAIM
    • optionally set ALERT_EMAIL
  3. install_update.sh

    • ensures Docker exists
    • ensures cron jobs exist
    • runs install if this is a new deployment
    • runs update if the stack already exists

Manual workflow

./manage-media-stack.sh install
./manage-media-stack.sh update
./manage-media-stack.sh status
./manage-media-stack.sh logs
./manage-media-stack.sh backup
./manage-media-stack.sh prune-backups
./manage-media-stack.sh restart
./manage-media-stack.sh stop
./manage-media-stack.sh check

Scheduled jobs installed automatically

  • Sunday 3:00 AM — Ubuntu updates
  • Sunday 3:30 AM — media stack update
  • Sunday 3:45 AM — old backup pruning
  • Every 15 minutes — service health monitor
  • Daily 2:00 AM — reboot if uptime is at least REBOOT_AFTER_DAYS
  • Daily 2:15 AM — disk usage check

Optional .env settings

In addition to the main path settings, you can tune these:

BACKUP_RETENTION_DAYS=30
REBOOT_AFTER_DAYS=30
DISK_ALERT_THRESHOLD=90
ALERT_EMAIL=

If ALERT_EMAIL is set and a local mailer is available, disk warnings are emailed as well as logged.

Example .env

TZ=America/New_York
PUID=1000
PGID=1000

APP_DATA=/media/apps/configs
MEDIA_MOVIES=/media/media_movies
MEDIA_TV=/media/media_tv
MEDIA_MUSIC=/media/media_music
MEDIA_VIDEOS=/media/media_videos
MEDIA_PHOTOS=/media/media_photos
MEDIA_DOWNLOADS=/media/media_downloads
TEMP_DOWNLOADS=/media/temp_downloads

REMOTE_SHARE_01=/mnt/remote_share_01
REMOTE_SHARE_02=/mnt/remote_share_02

PLEX_CLAIM=
PLEX_ADVERTISE_URL=

BACKUP_RETENTION_DAYS=30
REBOOT_AFTER_DAYS=30
DISK_ALERT_THRESHOLD=90
ALERT_EMAIL=

Notes

Plex claim token

For first-time server setup, place your claim token in:

PLEX_CLAIM=claim-xxxxxxxxxxxx

After the server is claimed and working, you can usually clear that value.

Intel Quick Sync / hardware transcoding

The Plex container maps /dev/dri:/dev/dri, which is typically what you want for Intel iGPU transcoding on Ubuntu.

Remote shares

The management script checks whether REMOTE_SHARE_01 and REMOTE_SHARE_02 are mounted before updates.

If you use SMB or NFS, configure those separately in /etc/fstab or your preferred mount process.

Disk alerts

disk-space-check.sh checks the main app and media paths using df. When usage reaches DISK_ALERT_THRESHOLD, it writes warnings to the cron log. If ALERT_EMAIL is set, it will also attempt to send an email.

Health monitor behavior

health-monitor.sh checks that the containers are running and performs simple HTTP checks against Plex, Sonarr, Radarr, and SABnzbd. If a service is down or unhealthy, it runs docker compose up -d <service> to recreate it.

Data safety

Do not remove your app config directories unless you intentionally want to reset the apps.

Important paths:

  • ${APP_DATA}/plex/library
  • ${APP_DATA}/radarr/data
  • ${APP_DATA}/sonarr/data
  • ${APP_DATA}/sabnzbd/config

About

Plex, radarr, sonarr - ubuntu server - containers!

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages