Building a Complete Media Server with Docker: Plex and SABnzbd Setup
Setting up a home media server has never been easier thanks to Docker containerization. In this comprehensive guide, I’ll walk you through…
Building a Complete Media Server with Docker: Plex and SABnzbd Setup
Setting up a home media server has never been easier thanks to Docker containerization. In this comprehensive guide, I’ll walk you through my media server setup that combines Plex Media Server with SABnzbd. This setup provides a solution for managing and streaming your media library.
What We’re Building
This configuration creates two essential services:
- Plex Media Server: For organizing, managing, and streaming your media collection
- SABnzbd: For automated downloading
Both services run in Docker containers, making them easy to deploy, update, and maintain while keeping your host system clean.
Prerequisites
Before diving in, ensure you have:
- A Linux server (Ubuntu, Debian, CentOS, etc.)
- Docker and Docker Compose installed
- Sufficient storage space for your media library
- Basic familiarity with command line operations
The Docker Compose Configuration
Let’s break down the docker-compose.yml file that orchestrates our media server:
Plex Media Server Configuration
plex:
container_name: plex
image: plexinc/pms-docker:latest
restart: unless-stopped
network_mode: host
environment:
- TZ=UTC
- PLEX_CLAIM=
- PLEX_UID=1000
- PLEX_GID=1000
volumes:
- /opt/dockerapp/plex/config:/config
- /mnt/media:/media
devices:
- /dev/dri:/dev/dri
Components Explained:
Container Image: plexinc/pms-docker:latest is the official Plex Docker image, automatically maintained by Plex Inc. Using latest ensures you get the most recent stable version.
Network Mode: network_mode: host is crucial for Plex functionality. This configuration allows Plex to use the host's network stack directly, which:
- Enables DLNA/UPnP discovery for devices on your network
- Improves streaming performance by reducing network overhead
- Allows Plex to automatically detect and use the optimal network settings
Environment Variables:
TZ=UTC: Sets the container's timezone. Replace with your local timezone (e.g.,America/New_York)PLEX_CLAIM: A temporary token for linking your server to your Plex account (obtain from https://plex.tv/claim))PLEX_UID/PLEX_GID: These should match your host user's ID to ensure proper file permissions
Volume Mounts:
/opt/dockerapp/plex/config:/config: Stores Plex's configuration, database, and metadata/mnt/media:/media: Your media library location - adjust this path to match your setup
Hardware Access: /dev/dri:/dev/dri provides access to hardware transcoding capabilities, significantly improving performance when converting media for different devices.
SABnzbd Configuration
sabnzbd:
container_name: sabnzbd
image: linuxserver/sabnzbd:latest
restart: unless-stopped
ports:
- "8080:8080"
environment:
- PUID=1000
- PGID=1000
- TZ=UTC
volumes:
- /opt/dockerapp/sabnzbd/config:/config
- /opt/dockerapp/sabnzbd/downloads:/downloads
- /mnt/media:/media
SABnzbd Breakdown:
Container Image: linuxserver/sabnzbd:latest from the LinuxServer.io team, known for well-maintained, security-focused containers.
Port Mapping: 8080:8080 exposes SABnzbd's web interface on port 8080. Unlike Plex, SABnzbd doesn't need host networking.
LinuxServer Environment Variables:
PUID/PGID: Similar to Plex's UID/GID but using LinuxServer's naming convention- These ensure downloaded files have correct ownership
Volume Strategy:
- Separate
/downloadsdirectory for temporary files during download/processing - Shared
/mediamount allows SABnzbd to place completed downloads where Plex can access them
The Startup Script Explained
The start-plex.sh script automates the deployment process:
#!/bin/bash
# Navigate to the docker-compose directory
cd /opt/dockerapp
# Pull latest images
docker compose pull
# Start the containers
docker compose up -d
# Show container status
docker ps
echo "Plex is available at http://localhost:32400/web"
echo "SABnzbd is available at http://localhost:8080"
Script Functionality:
- Directory Navigation: Ensures we’re in the correct location for Docker Compose operations
- Image Updates:
docker compose pulldownloads the latest versions of both container images - Service Startup:
docker compose up -dstarts containers in detached mode (background) - Status Check:
docker psdisplays running container information - User Information: Provides direct access URLs for both services
Directory Structure and Permissions
This setup assumes the following directory structure:
/opt/dockerapp/
├── docker-compose.yml
├── start-plex.sh
├── plex/
│ └── config/ # Plex configuration data
├── sabnzbd/
│ ├── config/ # SABnzbd configuration
│ └── downloads/ # Temporary download location
└── ...
/mnt/media/ # Your media library
├── movies/
├── tv/
├── music/
└── ...
Permission Setup: Ensure your media directories have appropriate permissions:
sudo chown -R 1000:1000 /opt/dockerapp/
sudo chown -R 1000:1000 /mnt/media/
chmod -R 755 /mnt/media/
Security Considerations
Network Security: While network_mode: host is necessary for Plex, it does expose the container to your host network. Ensure your firewall is properly configured.
Access Control: Both services should be placed behind a reverse proxy (like Nginx Proxy Manager or Traefik) for external access, rather than exposing ports directly.
User Permissions: Running containers with UID/GID 1000 follows the principle of least privilege while maintaining functionality.
Operational Benefits
Containerization Advantages:
- Isolation: Each service runs in its own container, preventing conflicts
- Portability: Easy to move between systems or backup configurations
- Updates: Simple image pulls for software updates
- Resource Management: Docker provides resource limiting and monitoring capabilities
Automation: The startup script enables:
- Consistent deployment procedures
- Easy system recovery after reboots
- Simplified maintenance workflows
Remember to always respect copyright laws and terms of service when using these tools, and ensure you have proper rights to any content you’re managing.
This setup has been running reliably in my home lab environment, serving multiple users across various devices. The containerized approach has made updates and maintenance significantly easier compared to traditional installations.
메타데이터
- post_id
- 7f2f6e40bb26
- slug
- building-a-complete-media-server-with-docker-plex-and-sabnzbd-setup-7f2f6e40bb26
- url
- https://medium.com/@me_35328/building-a-complete-media-server-with-docker-plex-and-sabnzbd-setup-7f2f6e40bb26
- canonical_url
- https://medium.com/@me_35328/building-a-complete-media-server-with-docker-plex-and-sabnzbd-setup-7f2f6e40bb26
- author_url
- https://medium.com/@me_35328
- status
- ok
- fetched_at
- 2026-07-18 01:40:03