qBittorrent
A docker container that will use a VPN connection as its network connection.
If the VPN drops or disconnects, the container will stop.
📋 Notes: assign_category.py
A script that will auto assign a category of an incoming torrent.
assign_category.py notes
📋 Notes: docker-compose-qbittorrent.yml
This docker-compose file is traditionally used to create and start a container from the command line. For Portainer we can just copy and paste this script into the web editor field.
docker-compose-qbittorrent.yml notes
This will create two services or containers called **qbittorrent** and **qbittorrent-openvpn**.
qbittorrent container
Key parts to this container are:
-
image:
- linuxserver/qbittorrent:latest: P2P bittorrent client specially built by the linuxserver.io team.
-
volumes:
/home/<USERNAME>/docker/qbittorrent/custom_scripts:/custom-cont-init.d:ro
This will be the location where the linuxserver.io image looks for custom scripts to run at the start of the container. Our custom scriptextra_packages.shwill need to go in this folder.
For more info you can see the documentation.
-
ports:
- The port section will not be used if we are using qbittorrent-openvpn container. All web traffic will be diverted threw that container.
-
healthcheck:
- A feature of Docker that will check to see if the container is healthy or exited (bad). You will need to change
<SERVER IP ADDRESS>to home server IP address.
In this configuration it will check to see if the container has a healthy network connection every 60 seconds. On 3 failed attempts it the container will get labeled asexited.
It is multiple ways or reasons to use healthcheck but for our purposes it will be used by theinspector_qb.pyscript which will reboot the container when needed.
- A feature of Docker that will check to see if the container is healthy or exited (bad). You will need to change
-
labels:
com.centurylinklabs.watchtower.depends-on: "qbittorrent-openvpn"- Used by watchtower to for starting and stopping containers. This container will not be rebooted beforeqbittorrent-openvpnhas already done so.
-
network_mode:
- Tells Docker that the all network activity to container
qbittorrentwill go threwqbittorrent-openvpncontainer.
- Tells Docker that the all network activity to container
-
depends_on:
- Tells Docker that the container
qbittorrentcan only be run/started ifqbittorrent-openvpnhas a healthy healthcheck status.
- Tells Docker that the container
qbittorrent-openvpn container
The only function of this container is to establish a VPN network connection.
Key parts to this container are:
-
image:
- haugene/transmission-openvpn: A Docker container used as an OpenVPN network tunnel.
-
cap_add:
- Since we are connecting to a VPN, this container will need admin access to network related functions.
-
ports:
- This will open up ports that
qbittorrentcontainer will need for networking.
The web port for alllinuxserver.ioimages are different in that both the<external>:<internal>ports have to be the same. Usually for most Docker containers your<external>port can change to whatever you want it to be BUT the<internal>port will have to stay the same.
I will be using port 8124 as indicated in the code below. The port can be changed, just remember that both port numbers will need to be the same for theqbittorrentcontainer to get a network connection.
8124:8124/tcp # qbittorrent web port 6881:6881/tcp # qbittorrent tcp connection port 6881:6881/udp # qbittorrent udp connection port
- This will open up ports that
-
environment
-
OpenVPN Provider Info: This is where you will enter your credentials from your VPN provider.
I am usingPrivadofor my VPN connection. You can use any provider that uses OpenVPN connections. For a list of supported providers that this container can use go here. You can also find the correct name to put in theOPENVPN_PROVIDERsection on the same part of the website.OPENVPN_PROVIDER=<PROVIDER NAME> OPENVPN_USERNAME=<PROVIDER USERNAME> OPENVPN_PASSWORD=<PROVIDER PASSWORD> OPENVPN_CONFIG=default -
Local Network: When the VPN has a successful connection, you wont be able to get to
qbittorrentweb gui. By setting this to your local network IP address range you will be able to access the gui from any IP address on your side of the router. To access the gui outside of your house, you will need to set up a reverse proxy in Synology NAS or similar.
-
📋 Notes: extra_packages.sh
A script that will be executed when the qbittorrent container is starting.
extra_packages.sh notes
This script goes in the /custom_script volume folder for qbittorrent container. It will install three programs.
- python3: This is the dependant programming language needed.
- pip3: Package install for python.
- qbittorrent-api: Client API used to interact with qbittorrent over web or CLI.
linuxserver.io uses Alpine OS to build all images. Alpine OS is a lighter version of linux compared to Linux Mint or Ubuntu. Because of this qbittorrent-api is not in the main repo for the OS. As of writing this doc its only edge branch repo. When this script is in the /custom_script folder is will get executed every time qbittorrent container is started ensuring that it will always be ready when qbittorrent is running.
The first part of the script links to the edge repo so we can download and install it.
# Add the "edge" testing repository
echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories
This will check for updates to the Alpine repo
# Update the package list
apk update
This will install Python3 first then install a version of pip3 for Alpine called py3-pip
# Install Python and pip
apk add python3 py3-pip
The last part of the script will install Alpines version of qbittorrent-api
# Install qbittorrent-api
apk add py3-qbittorrent-api
Note: Allecholines will be printed out to the logs and the terminal. This way if for whatever reason the script is not working you can search the logs to troubleshoot the issue.