Skip to content

Sonarr (GitHub release)

Ahmad Hadidi

Commands below use these values. Click any highlighted value in a code block to change it. Saved in this browser only.

Also uses your values: Template folder, Bridge, Gateway, CT disk storage, SSH public keys file, Data folder on the host, LAN proxy CTID, LAN proxy IP, Cloudflare tunnel CTID, Your domain, Your Access policy, Friend's Access policy, Friend's email

Pre-requisites

  1. Mounting and User mapping
  2. Data folder for Sonarr downloads ready

Install

CT Creation

Proxmox host
{
read -rs -p "Root password for the new CT: " PW; echo
pct create \
112 \
/mnt/pve/evo/template/cache/alpine-3.24-default_20260714_amd64.tar.xz \
--hostname sonarr \
--memory 512 \
--net0 name=eth0,bridge=vmbr0,firewall=1,gw=192.168.0.1,ip=192.168.0.112/24,hwaddr=DE:AD:DE:AD:01:12,type=veth \
--rootfs local-lvm:1 \
--unprivileged 1 \
--ignore-unpack-errors \
--ostype alpine \
--password="$PW" \
--ssh-public-keys /root/.ssh/authorized_keys \
--start 0
unset PW
}

Storage Mapping

Proxmox host
echo "mp0: /mnt/pve/evo/data,mp=/data" >> /etc/pve/lxc/112.conf
echo "lxc.idmap: u 0 100000 1000" >> /etc/pve/lxc/112.conf
echo "lxc.idmap: g 0 100000 1000" >> /etc/pve/lxc/112.conf
echo "lxc.idmap: u 1000 1000 1" >> /etc/pve/lxc/112.conf
echo "lxc.idmap: g 1000 1000 1" >> /etc/pve/lxc/112.conf
echo "lxc.idmap: u 1001 101001 64535" >> /etc/pve/lxc/112.conf
echo "lxc.idmap: g 1001 101001 64535" >> /etc/pve/lxc/112.conf

Enter the CT

Proxmox host
pct start 112 && pct enter 112

Enable DHCP Leasing - Alpine

In CT
# Alpine
touch /hdd_request_ip.sh
echo "udhcpc -i eth0 -F $(hostname) -x hostname:$(hostname) -r $(hostname -i)" >> /hdd_request_ip.sh
echo -e "#!/sbin/openrc-run\n\
name=hdd_request_ip\n\
description=\"Request IP Address From Router\"\n\
command=\"sh ./hdd_request_ip.sh\"\n\
command_background=true\n\
pidfile=\"/run/\$name.pid\"\n\
# output_log=\"/var/log/homepage/output.log\"\n\
# error_log=\"/var/log/homepage/error.log\"\n\
\ndepend() {\n\
\tneed net\n\
\tuse dns logger netmount\n\
}" >> /etc/init.d/hdd_request_ip
chmod +x /etc/init.d/hdd_request_ip
rc-update add hdd_request_ip
service hdd_request_ip start

User at uid 1000

In CT
addgroup -g 1000 sonarr
adduser -D -h /var/lib/sonarr -s /sbin/nologin -G sonarr -u 1000 sonarr

Dependencies

In CT
apk add libstdc++ icu-libs sqlite-libs tzdata

Install Sonarr

In CT
VERSION=$(wget -qO- https://api.github.com/repos/Sonarr/Sonarr/releases/latest | tr ',' '\n' | grep '"tag_name"' | cut -d'"' -f4 | sed 's/^v//')
wget -O /tmp/sonarr.tar.gz "https://github.com/Sonarr/Sonarr/releases/download/v$VERSION/Sonarr.main.$VERSION.linux-musl-x64.tar.gz"
mkdir -p /opt/sonarr
tar xzf /tmp/sonarr.tar.gz -C /opt/sonarr --strip-components=1
rm -rf /opt/sonarr/Sonarr.Update /tmp/sonarr.tar.gz

Service

In CT
cat > /etc/init.d/sonarr <<'EOF'
#!/sbin/openrc-run
name=sonarr
description="Sonarr"
command=/opt/sonarr/Sonarr
command_args="-nobrowser -data=/var/lib/sonarr"
command_user=sonarr:sonarr
supervisor=supervise-daemon
output_log=/var/log/sonarr/output.log
error_log=/var/log/sonarr/output.log

depend() {
	need net
	after firewall
}

start_pre() {
	checkpath -d -o $command_user /var/lib/sonarr /var/log/sonarr
}
EOF
chmod +x /etc/init.d/sonarr
rc-update add sonarr

Data folder

In CT
chmod 770 /data -R
chown 1000:1000 -R /data

Start

In CT
rc-service sonarr start

You’re done

Your browser
http://192.168.0.112:8989

Heart Beat

Your browser
http://192.168.0.112:8989/ping

Optional: reach it at sonarr.lan

Needs the Nginx LAN proxy. Run this on the node that hosts the proxy.

Proxmox host
pct exec 101 -- add-lan-app sonarr.lan 192.168.0.112 8989
MikroTik
/ip dns static add name=sonarr.lan address=192.168.0.101

Optional: reach it through the Cloudflare tunnel

Needs the Cloudflared tunnel. On the node that hosts it:

Proxmox host
pct exec 102 -- add-cf-app sonarr.hadidi.art 192.168.0.112 8989
pct exec 102 -- protect-cf-app sonarr.hadidi.art "HDD"
# Share with a friend
pct exec 102 -- add-cf-policy "Friend" friend@example.com
pct exec 102 -- protect-cf-app --add sonarr.hadidi.art "Friend"

Update

Update Sonarr

In CT
VERSION=$(wget -qO- https://api.github.com/repos/Sonarr/Sonarr/releases/latest | tr ',' '\n' | grep '"tag_name"' | cut -d'"' -f4 | sed 's/^v//')
wget -O /tmp/sonarr.tar.gz "https://github.com/Sonarr/Sonarr/releases/download/v$VERSION/Sonarr.main.$VERSION.linux-musl-x64.tar.gz"
rc-service sonarr stop
rm -rf /opt/sonarr
mkdir -p /opt/sonarr
tar xzf /tmp/sonarr.tar.gz -C /opt/sonarr --strip-components=1
rm -rf /opt/sonarr/Sonarr.Update /tmp/sonarr.tar.gz
rc-service sonarr start

Remove

Remove from the LAN proxy

Only if you added it to the Nginx LAN proxy. Run this on the node that hosts the proxy.

Proxmox host
pct exec 101 -- sed -i '/^ *sonarr\.lan /d' /etc/nginx/http.d/map-backends.conf
pct exec 101 -- nginx -s reload
MikroTik
/ip dns static remove [find name=sonarr.lan]

Remove from the Cloudflare tunnel

Only if you added it to the Cloudflared tunnel. Run this on the node that hosts the tunnel.

Proxmox host
pct exec 102 -- del-cf-app sonarr.hadidi.art

Delete the CT

Proxmox host
pct stop 112
pct destroy 112