Setup Sonarr in Docker to automate & manage your Plex TV Shows
Sonarr is a PVR for Usenet and BitTorrent users. It can monitor multiple RSS feeds for new episodes of your favorite shows and will grab, sort and rename them. It can also be configured to automatically upgrade the quality of files already downloaded when a better quality format becomes available.
We'll be installing Sonarr in Docker. For other platforms, take a look at Sonarr's official documentation here.
Since Sonarr doesn't have any official docker image, we'll be using LinuxServer's Sonarr Docker image.
Supported Architectures
Their images support multiple architectures such as x86-64
, arm64
and armhf
. We utilize the docker manifest for multi-platform awareness. More information is available from docker here and their announcement here.
Simply pulling lscr.io/linuxserver/sonarr
should retrieve the correct image for your arch, but you can also pull specific arch images via tags.
The architectures supported by this image are:
Architecture | Tag |
---|---|
x86-64 | amd64-latest |
arm64 | arm64v8-latest |
armhf | arm32v7-latest |
Version Tags
This image provides various versions that are available via tags. latest
tag usually provides the latest stable version. Others are considered under development and caution must be exercised when using them.
Tag | Description |
---|---|
latest | Stable releases from Sonarr (currently v3) |
develop | Development releases from Sonarr (currently v3) |
develop-alpine | Development releases from Sonarr (currently v3) using our Alpine baseimage |
Installation
To help you get started creating a container from this image you can either use the docker CLI or docker-compose.
docker CLI
docker run -d \
--name=sonarr \
-e PUID=1000 \
-e PGID=1000 \
-e TZ=Europe/London \
-p 8989:8989 \
-v /path/to/data:/config \
-v /path/to/media:/media `#optional` \
--restart unless-stopped \
lscr.io/linuxserver/sonarr
Go down to the parameters section for more info.
docker-compose
---
version: "2.1"
services:
sonarr:
image: lscr.io/linuxserver/sonarr
container_name: sonarr
environment:
- PUID=1000
- PGID=1000
- TZ=Europe/London
volumes:
- /path/to/data:/config
- /path/to/media:/media #optional
ports:
- 8989:8989
restart: unless-stopped
Parameters
Docker images are configured using parameters passed at runtime (such as those above). These parameters are separated by a colon and indicate <external>:<internal>
respectively. For example, -p 8080:80
would expose port 80
from inside the container to be accessible from the host's IP on port 8080
outside the container.
Ports (-p
)
Parameter | Function |
---|---|
8989 | The port for the Sonarr webinterface |
Environment Variables (-e
)
Env | Function |
---|---|
PUID=1000 | for UserID - see below for explanation |
PGID=1000 | for GroupID - see below for explanation |
TZ=Europe/London | Specify a timezone to use EG Europe/London, this is required for Sonarr. See here for your timezone code. |
Volume Mappings (-v
)
Volume | Function |
---|---|
/config | Database and Sonarr configs |
/media | Location of Media & Downloads library on disk |
Note:
Be sure to put your downloads on the same drive and mount them in Docker as your media. This helps maintain hardlinks (a way for a file to exist in multiple places on the same file system while only consuming one file worth of space) and atomic move (instant file moves, rather than copy+delete) while processing content.
The folks over at servarr.com wrote a good write-up on how to get started with this.
Other parameters
- To use host network mode, simply add network_mode: "host" to docker-compose or --net=host to docker-CLI.
- If you are managing docker containers via systemd like me (see below), set the restart policy to no.
- To limit CPU threads for this container, add cpus: value to docker-compose or --cpus=value to docker-CLI. Here value is the number of cpu threads. For instance, if the host machine has four CPU threads and you set --cpus="1.5", the container is guaranteed at most one and a half of the CPU threads.
After this, you can access the WebUI at <your-ip>:8989
, for more information check out Sonarr.
Umask for running applications
For all of their images, they provide the ability to override the default umask settings for services started within the containers using the optional -e UMASK=022
setting. Keep in mind umask is not chmod it subtracts from permissions based on its value it does not add. Please read up here before asking for support.
User / Group Identifiers
When using volumes (-v
flags), permissions issues can arise between the host OS and the container, we avoid this issue by allowing you to specify the user PUID
and group PGID
.
Ensure any volume directories on the host are owned by the same user you specify and any permissions issues will vanish like magic.
In this instance PUID=1000
and PGID=1000
, to find your use id user
as below:
$ id username
uid=1000(dockeruser) gid=1000(dockergroup) groups=1000(dockergroup)
Docker Mods
LinuxServer publishes various Docker Mods to enable additional functionality within the containers. The list of Mods available for this image (if any), as well as universal mods that can be applied to any one of their images, can be accessed via the link below.
Important Commands
Shell access whilst the container is running:
docker exec -it sonarr /bin/bash
To monitor the logs of the container in realtime:
docker logs -f sonarr
Container version number:
docker inspect -f '{{ index .Config.Labels "build_version" }}' sonarr
Image version number:
docker inspect -f '{{ index .Config.Labels "build_version" }}' lscr.io/linuxserver/sonarr
Managing Sonarr Docker via Systemd
Here's my systemd file
[Unit]
Description=Docker sonarr
After=media-drive.mount
Requires=media-drive.mount
StartLimitIntervalSec=10
StartLimitBurst=5
[Service]
Type=simple
ExecStart=/usr/bin/docker start -a sonarr
ExecStop=/usr/bin/docker stop sonarr
Restart=always
RestartSec=60s
[Install]
WantedBy=media-drive.mount
Note: I start all my docker containers after I have mounted my external hard drive, therefore the media-drive.mount is for that.
For a more generic systemd service,
[Unit]
Description=Docker sonarr
After=network-online.target
Requires=network-online.target
StartLimitIntervalSec=10
StartLimitBurst=5
[Service]
Type=simple
ExecStart=/usr/bin/docker start -a sonarr
ExecStop=/usr/bin/docker stop sonarr
Restart=always
RestartSec=60s
[Install]
WantedBy=multi-user.target
Now to start, stop, or restart the sonarr docker container, you would just use,
sudo systemctl start sonarr.service
sudo systemctl stop sonarr.service
sudo systemctl restart sonarr.service
Note: If you are managing docker containers via systemd like this, DONT use docker restart policies and docker start/stop commands separately. If you stop a container directly via the docker stop command, this systemd service will just restart it after a 60s interval. Also, be sure to set a restart=no flag for your container.
Configuration
For detailed instructions on configuring Sonarr, take a look at Sonarr's official documentation here.
Some Key Points from my configuration
- I have set up 3 separate sonarr instances on my server. one for 1080p, one for 4K, and another for Dolby Vision.
- All 3 of them are just different docker containers with the same images but different sonarr config folders.
- To give more resources to my Plex server and other services, I have limited Sonarr containers to 2.5 out of 4 CPU threads that I have.
- Also, I am running these containers in host network mode and have changed their ports from Sonarr's settings and I am managing them via systemd instead of docker restart policies.
1080p Sonarr Instance
My 1080p Release Profile
Preferren Word | Score |
---|---|
EZTV | 2 |
eztv | 2 |
Minx | 1 |
Megusta | 1 |
h265 | 1 |
x265 | 1 |
HEVC | 1 |
ettv | 1 |
ETTV | 1 |
x264 | 0 |
h264 | 0 |
DV | -4 |
dolby | -4 |
dolbyvision | -4 |
dv | -4 |
Also in the Release Profiles, I use the following restrictions
My 1080p Quality Size Limit
Quality | Min | Max |
---|---|---|
HDTV-1080p | 3 | 129.3 |
WEBDL-1080p | 3.6 | 130.5 |
WEBRip-1080p | 4 | 130 |
Bluray-1080p | 3.7 | 129.6 |
My Indexers
All of the indexers are configured via Jackett except the duplicate Rarbg one.
4K Sonarr Instance
My 4K Release Profile
Preferren Word | Score |
---|---|
EZTV | 2 |
eztv | 2 |
HEVC | 1 |
h265 | 1 |
x265 | 1 |
MeGusta | 1 |
Minx | 1 |
ETTV | 1 |
ettv | 1 |
h264 | 0 |
x264 | 0 |
DV | -4 |
dolby | -4 |
dolbyvision | -4 |
dv | -4 |
My 4K Quality Size Limit
Quality | Min | Max |
---|---|---|
HDTV-2160p | 1.1 | 179 |
WEBDL-2160p | 1.1 | 179.4 |
WEBRip-2160p | 3 | 178.6 |
Bluray-2160p | 1.3 | 188.2 |
Dolby Vision Sonarr Instance
My 4K Release Profile
Preferren Word | Score |
---|---|
EZTV | 2 |
eztv | 2 |
DV | 1 |
HEVC | 1 |
x265 | 1 |
h265 | 1 |
Minx | 1 |
MeGusta | 1 |
MKV | 1 |
dolby | 1 |
dolbyvision | 1 |
ettv | 1 |
ETTV | 1 |
vision | 1 |
MP4 | -1 |
x264 | -4 |
h264 | -4 |
Also in the Release Profiles, I use the following restrictions
My 4K Quality Size Limit
Quality | Min | Max |
---|---|---|
HDTV-2160p | 1.1 | 221.9 |
WEBDL-2160p | 1.1 | 227.9 |
WEBRip-2160p | 3 | 226.2 |
Bluray-2160p | 1.3 | 256.5 |
That's it.
This should help you set up and configure Sonarr for the most part.
For any doubts, feel free to comment below.