Setting up a media server with docker, Jellyfin, Deluge, Sonarr and Radarr

Hey,
if you’re a data hoarder like me, or are someone who just wishes to have a neat way to showcase your media, then this post might be of use to you.
To begin with, I’ll offer a concise explanation to the stack I’ll be using.

  • Jellyfin
    Jellyfin simply gives you a nice UI to browse your media in. You give it the path to your media library, which, keep in mind, has to be tidy, divided into subfolders with clear names of Movies, or TV Shows.
    Something like this
media
├── movies
│   ├── All Quiet on the Western Front (2022)
│   ├── AlphaGo (2017)
|   ├── (...)
│   ├── A Man Called Ove (2015)
│   └── Zack Snyder's Justice League (2021)
└── tv
    ├── 1883
    ├── Ancient Aliens
    ├── (...)
    ├── The Last Dance
    └── Yellowstone (2018)

And after you’re done, you’ll have an interface that looks something like this

  • Sonarr
    Manually arranging all these shows and movies into their respective folders with names and release years is a hassle, so sonarr does this for us (only for shows). We let it communicate with our download client, and it grabs whatever our download client downloads and arranges it all neatly into our media folder (more on this later).
  • Radarr
    Radarr does what sonarr does, but for movies.
  • Deluge
    This is what downloads our content.

Now that you’re familiar with your tech stack, let’s start.

Docker

By far the simplest way to set up your media server is using docker. Docker is a platform for running applications in lightweight, isolated containers, making it easier to deploy and manage software across different systems. Since I’m running my server on a headless spare computer in my home, I don’t need the GUI version of docker, I’ve installed the docker engine. Installing docker engine on ubuntu. Make sure you also install docker-compose. You might also want to look at this, so you don’t need to be root to run docker commands.
Now, I have all my data on a 2TB external drive. I mount it on /mnt/2 TB Hard Disk, but I’ve symlinked ~/media_server to that location, and you can do the same. For reference, this is my fstab entry for the drive

/dev/disk/by-uuid/A89E4BAF9E4B753A /mnt/2\040TB\040Hard\040Disk auto nosuid,nodev,nofail,x-gvfs-show,x-gvfs-name=2%20TB%20Hard%20Disk 0 0
view raw fstab.txt hosted with ❤ by GitHub

So from now on, I refer to the root directory of the media server as ~/media_server.

Structure

Since our root folder probably differ, set the environment variable ROOT to be your root folder. Mine would then be set to /mnt/2 TB Hard Disk/media_server
This is what our folder structure looks like

$ROOT
├── config
│   ├── deluge
│   ├── jellyfin
│   ├── radarr
│   └── sonarr
├── docker-compose.yml
├── .env
├── media
│   ├── books
│   ├── movies
│   └── tv
└── torrents
    ├── complete
    ├── incomplete
    └── torrent_files

Create the directories with these commands, but make sure you’ve exported your ROOT variable, like export ROOT=/mnt/2\ TB\ Hard\ Disk/media_server for me.

cd ${ROOT}
mkdir -p config media torrents
mkdir -p config/deluge config/jellyfin config/radarr config/sonarr
mkdir -p media/movies media/tv
mkdir -p torrents/complete torrents/incomplete torrents/torrent_files
touch docker-compose.yml .env
view raw create_dirs.sh hosted with ❤ by GitHub

Our config is stored in root/config. The torrents that our download client downloads are stored in root/torrents/complete, while they are incomplete, that is, still downloading, the will be stored in root/torrents/incomplete. The torrent files you upload to deluge are stored in root/torrents/torrent_files.

Docker Compose

Docker Compose is an extension to docker for running your multi-container applications. It lets you write all the important details in a simple YAML file, like what containers you need, how they talk to each other, and what things they need to share. With Docker Compose, you can start, stop, and scale your containers with a single command.
Start by creating a docker-compose.yml and a .env file in the root directory.
Make the .env file look something like this

Here’s a brief explanation to what each section of this docker-compose.yml means

  • deluge
    Directly uses hosts network stack, always restarts, even on failure or system reboot, process UID and GUID as set in .env, uses root/config/deluge as its configuration folder.
    The line - ${ROOT}:/data means, to deluge, /data points to our root folder. For example, /data/hello.txt would translate to the file /mnt/2 TB Hard Disk/hello.txt on my system. We’ll use this while configuring Deluge.
  • radarr, sonarr
    Pretty much the same
  • jellyfin
    Here, to jellyfin, /data points to root/media. Be careful, this might be confusing, because in deluge, /data pointed to root.
    while jellyfin is transcoding video when serving to users, it needs a directory to temporarily store files. Usually these files are not too big big in size, so I decided to store them in /dev/shm. The /dev/shm directory is a virtual filesystem that allows processes to share memory using temporary files. It stands for “shared memory” and is typically mounted as a RAM-based filesystem. Simply put, the files you put in it are stored in RAM, rather than persistent storage.

Starting and Configuration

Now, start and stop all the containers with
cd ${ROOT} && docker compose up && docker compose down -d --remove-orphans
This will generate the initial configuration.

Deluge

First, you need to add a username and password to authenticate with when you connect to the deluge running on our server.
You have to allow remote connections by changing the line "allow_remote": false, in config/deluge/core.conf to true. and the file ${ROOT}/config/deluge/auth and add a username and password to, like this

username:password:10

Make sure the container isn’t running while you’re doing this. The 10 signifies an admin account. Now start only the deluge container with docker compose up deluge -d.
Now install the deluge client. You can do this on any machine, since you’ll only use this client to access the deluge running on our server.

sudo add-apt-repository ppa:deluge-team/stable
sudo apt-get update
sudo apt-get install deluge-gtk

Launch deluge-gtk, and open host manager with ctrl+m and add your machine’s ip in the host field, and the user and password you created before.

Open preferences with ctrl+p, and go to the downloads section.
Set the download folder path to /data/torrents/incomplete.
Set the move completed path to/data/torrents/complete.
Set the copy of .torrent path to/data/torrents/torrent_files.
Go to the plugins section, and enable the Label plugin, then apply these settings.
Add 3 new labels, sonarr, radarr and other by right clicking on the Labels section in the left column and clicking on Add label.

Now try adding a test torrent to see if it’s downloading correctly
Click on the plus button on the top left to add a torrent, and click on url, and enter this url

magnet:?xt=urn:btih:d984f67af9917b214cd8b6048ab5624c7df6a07a&tr=https%3A%2F%2Facademictorrents.com%2Fannounce.php&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337%2Fannounce

After adding, right click it in the torrents list view and change its label to others.
Hopefully it starts downloading.

Sonarr

Keep the deluge container running, and start the sonarr container with docker compose up sonarr -d.
Now open your browser on any machine, and go to you server’s IP on port 8989, something like http://192.168.1.34:8989/
Go to settings on the left column, and to Media Management
Check the Rename Episodes box.
At the bottom, click on Add Root Folder, and add /data/media/tv. Remember, this points to ${ROOT}/media/tv, where our TV Shows are stored. Click on saves changes at the top. Finally, it should look something like this

Now go to Download Clients > Add Client > Deluge.
Name it anything, I’ve simply named it Deluge. Change the category to sonarr, and check Remove imported downloads from download client history (when finished seeding for torrents) at the bottom. Click on test, and if it shows a green tick, you’re good to go. If not, make sure the deluge container is running and you’ve followed deluge’s configuration correctly.

Radarr

Start the radarr docker container like you’ve done before, and go to your server’ip address on port 7878.
Go to Settings > Media Management. Check the Rename Movies box and add a root folder from the bottom with the path /data/media/movies. Save Changes.
Add deluge to the download clients exactly like you did with Sonarr, make sure its category is radarr

Jellyfin

Start the jellyfin container, and go to your computer’s ip on port 8096.
Pick your username and password, and click on Add Library. Set the Content Type to Movies, and the path to /data/movies
Add another media library with Content Type as Shows and path as /data/tv. Also tick the Automatically merge series that are spread across multiple folders box.
Continue setup.

You’re done

This finishes our setup, let’s try adding some content.
Try adding this magnet url to your deluge client, make sure you set its label as radarr.

magnet:?xt=urn:btih:e8fa958a8f275bf6e00878411850efa67a92e921&dn=Sanju (2018) [BluRay] [1080p] [YTS.AM]&tr=udp://tracker.coppersurfer.tk:6969/announce&tr=udp://9.rarbg.com:2710/announce&tr=udp://p4p.arenabg.com:1337&tr=udp://tracker.internetwarriors.net:1337&tr=udp://tracker.opentrackr.org:1337/announce

Use this command to restart all the components of your media server.

cd ${ROOT} && docker compose down && docker compose up -d –remove-orphans
view raw restart.sh hosted with ❤ by GitHub

Make sure to replace ${ROOT} with the root folder of your media server data.
Read over the documentations of each of the programs you’ve used if you run into a problem, or post a comment down below.

Now, go to radarr, that is, your computer’s ip on port 7878.
Go to add new, and search the movie’s name. It might take some time to load. Click on the movie, and Add Movie. If everything is working fine, it would show the movie as downloading, because it’s radarr asked our download client about the movie, and saw that it was already downloading.
Hopefully, the movie shows up in Jellyfin, but you might have to re-scan your movies’ library by right click > scan for new metadata.
Adding to a TV Show should be the same, but do that in sonarr, and set its label in deluge to sonarr.

End Notes

I hope this blog post provided you with at least some useful information. Please leave a comment down below to let me know.
If you find any mistakes, please reach out to me at agastya.singh@live.com
Thank you for reading.


2 responses to “Setting up a media server with docker, Jellyfin, Deluge, Sonarr and Radarr”

  1. The docker-compose.yml file is not even rendered in the link provided…

    So much for “No BS”.

    Like

Leave a comment

Design a site like this with WordPress.com
Get started