Building a Media Server with Plex, Sonarr, and Radarr
There's something deeply satisfying about having your entire media library at your fingertips. No more hunting through streaming services, no more "this title is not available in your region," and no more watching your favorite shows disappear when a platform loses the rights. A self-hosted media server puts you back in control.
In this guide, I'll walk you through setting up the holy trinity of home media: Plex for playback, Sonarr for TV shows, and Radarr for movies. We'll tie it all together with Docker Compose so you can spin up your entire stack with a single command. By the end, you'll have an automated system that downloads, organizes, and serves your media beautifully.
Understanding the Stack
Before we dive into configuration files, let's understand what each piece does and how they work together. Think of it like an assembly line for your media.
Plex: The Frontend
Plex is your media server's face. It's what you actually interact with when you want to watch something. Plex scans your media folders, fetches metadata (posters, plot summaries, cast info), and serves everything through a slick interface. You can access it from your browser, smart TV, phone, or pretty much any device with a screen.
Plex handles transcoding too. Got a 4K file but your phone can only handle 1080p? Plex converts it on the fly. This is where having a decent CPU (or a GPU for hardware transcoding) really pays off.
Sonarr: The TV Show Manager
Sonarr is your personal TV assistant. You tell it which shows you want to watch, and it handles the rest. It monitors for new episodes, searches your preferred indexers, sends downloads to your download client, and then renames and organizes the files when they're done.
The magic happens automatically. New episode of your favorite show airs on Tuesday? By Wednesday morning, it's sitting in your Plex library, properly named and ready to watch.
Radarr: The Movie Manager
Radarr is Sonarr's sibling, but for movies. Add a movie to your watchlist, and Radarr will hunt it down. It's particularly useful for upcoming releases. Add a movie that's still in theaters, and Radarr will grab it automatically once a quality release becomes available.
How They Connect
Here's the flow:
- You add a show to Sonarr or a movie to Radarr
- Sonarr/Radarr searches your configured indexers (like Prowlarr or Jackett)
- When found, it sends the download to your download client (like qBittorrent or Transmission)
- Once complete, Sonarr/Radarr imports the file, renames it properly, and moves it to your media folder
- Plex detects the new file and adds it to your library
All of this happens without you lifting a finger after the initial setup.
Planning Your Folder Structure
Before we start deploying containers, we need to plan our folder structure. Getting this right from the start saves you headaches later. Trust me on this one.
The key principle: all your containers need to see the same paths. If Sonarr sees a file at /data/tv/Show Name/Season 1/episode.mkv, Plex needs to see it at exactly the same path. This is why we use a shared data directory.
Recommended Structure
/srv/media/
├── data/
│ ├── movies/ # Your movie library
│ ├── tv/ # Your TV show library
│ └── downloads/ # Where your download client saves files
│ ├── complete/ # Finished downloads
│ └── incomplete/ # In-progress downloads
└── config/
├── plex/ # Plex configuration and database
├── sonarr/ # Sonarr configuration
└── radarr/ # Radarr configuration
Why this structure? A few reasons:
- Atomic moves: When downloads complete, Sonarr/Radarr can do instant "hardlinks" or moves instead of slow copies, because everything is on the same filesystem
- Clean separation: Config files are separate from media, making backups easier
- Single mount point: You only need to mount
/srv/mediato each container
Create these directories before starting:
mkdir -p /srv/media/data/{movies,tv,downloads/{complete,incomplete}}
mkdir -p /srv/media/config/{plex,sonarr,radarr}
The Docker Compose File
Now for the main event. Here's a complete Docker Compose file that sets up Plex, Sonarr, and Radarr. I'm also including qBittorrent as a download client since you'll need one.
version: "3.8"
services:
plex:
image: lscr.io/linuxserver/plex:latest
container_name: plex
network_mode: host
environment:
- PUID=1000
- PGID=1000
- TZ=Europe/London
- VERSION=docker
volumes:
- /srv/media/config/plex:/config
- /srv/media/data:/data
restart: unless-stopped
sonarr:
image: lscr.io/linuxserver/sonarr:latest
container_name: sonarr
environment:
- PUID=1000
- PGID=1000
- TZ=Europe/London
volumes:
- /srv/media/config/sonarr:/config
- /srv/media/data:/data
ports:
- 8989:8989
restart: unless-stopped
radarr:
image: lscr.io/linuxserver/radarr:latest
container_name: radarr
environment:
- PUID=1000
- PGID=1000
- TZ=Europe/London
volumes:
- /srv/media/config/radarr:/config
- /srv/media/data:/data
ports:
- 7878:7878
restart: unless-stopped
qbittorrent:
image: lscr.io/linuxserver/qbittorrent:latest
container_name: qbittorrent
environment:
- PUID=1000
- PGID=1000
- TZ=Europe/London
- WEBUI_PORT=8080
volumes:
- /srv/media/config/qbittorrent:/config
- /srv/media/data/downloads:/data/downloads
ports:
- 8080:8080
- 6881:6881
- 6881:6881/udp
restart: unless-stopped
prowlarr:
image: lscr.io/linuxserver/prowlarr:latest
container_name: prowlarr
environment:
- PUID=1000
- PGID=1000
- TZ=Europe/London
volumes:
- /srv/media/config/prowlarr:/config
ports:
- 9696:9696
restart: unless-stopped
Save this as docker-compose.yml in a directory of your choice (I like /srv/media/), then run:
docker compose up -d
All five services will start up and begin running in the background.
Understanding the Configuration
Let me break down some key parts of this compose file:
PUID and PGID: These set the user and group ID that the containers run as. Run id in your terminal to find your user's values. This ensures files created by the containers are owned by your user, not root.
Network mode host (Plex): Plex uses host networking for better performance with DLNA and remote access. This means it binds directly to your machine's network interface rather than going through Docker's network layer.
Shared /data volume: Notice how Plex, Sonarr, and Radarr all mount /srv/media/data:/data. This is crucial. They all see the same filesystem paths, which enables hardlinking and instant moves.
Prowlarr: I snuck this one in because it makes life much easier. Prowlarr is an indexer manager that syncs your indexers to Sonarr and Radarr. Configure your indexers once in Prowlarr, and it pushes them to all your apps.
Initial Configuration
With everything running, let's configure each service. Access them through your browser:
- Plex:
http://your-server-ip:32400/web - Sonarr:
http://your-server-ip:8989 - Radarr:
http://your-server-ip:7878 - qBittorrent:
http://your-server-ip:8080 - Prowlarr:
http://your-server-ip:9696
Step 1: Configure qBittorrent
The default login is usually admin with a randomly generated password (check the container logs with docker logs qbittorrent). Once logged in:
- Go to Settings > Downloads
- Set Default Save Path to
/data/downloads/complete - Set Keep incomplete torrents in to
/data/downloads/incomplete - Change your password to something secure
Step 2: Set Up Prowlarr
- Add your indexers under Indexers > Add Indexer
- Go to Settings > Apps
- Add Sonarr and Radarr as applications
- For the Prowlarr Server, use
http://prowlarr:9696 - For Sonarr/Radarr servers, use
http://sonarr:8989andhttp://radarr:7878 - You'll need the API keys from each app (found in Settings > General)
Step 3: Configure Sonarr
- Go to Settings > Media Management
- Click "Add Root Folder" and set it to
/data/tv - Enable "Rename Episodes" and configure your preferred naming scheme
- Go to Settings > Download Clients
- Add qBittorrent with host
qbittorrent, port8080, and your credentials
Step 4: Configure Radarr
Same process as Sonarr:
- Go to Settings > Media Management
- Add Root Folder as
/data/movies - Add qBittorrent as your download client (same settings as Sonarr)
Step 5: Set Up Plex
- Walk through the initial setup wizard
- Add your libraries: Movies pointing to
/data/movies, TV Shows pointing to/data/tv - Enable automatic library scanning in Settings > Library
Pro Tips for a Better Experience
Enable Hardlinks
If you followed the folder structure above, you're already set up for hardlinks. These let Sonarr and Radarr "copy" files instantly without using extra disk space. The download and the library file point to the same data on disk.
In Sonarr/Radarr, go to Settings > Media Management and ensure "Use Hardlinks instead of Copy" is enabled.
Quality Profiles
Don't just grab everything in the highest quality available. Set up quality profiles that match your needs. Maybe you want 1080p for most content but 4K for movies you really care about. Both Sonarr and Radarr let you create custom profiles.
Connect Plex to Sonarr/Radarr
In Sonarr and Radarr, go to Settings > Connect and add Plex as a connection. This makes Plex refresh immediately when new content arrives instead of waiting for the scheduled scan.
Backup Your Config
The /srv/media/config directory contains all your settings, databases, and preferences. Back this up regularly. Your media can be re-downloaded, but your watch history, custom settings, and configurations take time to recreate.
Hardware Transcoding
If you have an Intel CPU with Quick Sync or an NVIDIA GPU, you can enable hardware transcoding in Plex. This dramatically reduces CPU usage during playback. For the Docker container, you'll need to pass through the appropriate device. For Intel Quick Sync:
devices:
- /dev/dri:/dev/dri
Wrapping Up
You now have a fully automated media server. Add shows and movies through Sonarr and Radarr, and they'll magically appear in Plex. The system monitors for new episodes, handles downloads, organizes files with proper naming, and keeps everything tidy.
This setup scales well too. You can add more services over time: Lidarr for music, Readarr for books, Overseerr for a request system that lets family members ask for content. They all follow the same patterns and integrate seamlessly.
The initial setup takes an hour or two, but once it's running, you'll wonder how you ever lived without it. No more manual downloads, no more messy folder structures, no more "what streaming service has this?" moments. Just your content, your way, available everywhere.
Welcome to the world of self-hosted media. Your TV will never be the same.