Docker container which runs a headless qBittorrent client with WebUI and optional OpenVPN
100K+
Docker container running the latest headless qBittorrent client with WebUI, connected through OpenVPN with an iptables kill switch to prevent IP leaks if the VPN tunnel drops.
1.1.1.1 and Quad9 9.9.9.9)This is the easiest way to run the container, especially on a Raspberry Pi.
mkdir -p ~/qbittorrent/config/openvpn
mkdir -p ~/qbittorrent/downloads
Copy your .ovpn file from your VPN provider into the config/openvpn/ directory:
cp /path/to/your-vpn.ovpn ~/qbittorrent/config/openvpn/
docker-compose.ymlservices:
qbittorrent:
image: aiwi/docker-qbittorrentvpn
container_name: qbittorrent
restart: unless-stopped
privileged: true
devices:
- /dev/net/tun
volumes:
- ./config:/config
- ./downloads:/downloads
environment:
- VPN_ENABLED=yes
- LAN_NETWORK=192.168.1.0/24
- NAME_SERVERS=1.1.1.1,9.9.9.9
- PUID=1000
- PGID=1000
ports:
- 8080:8080
- 8999:8999
- 8999:8999/udp
Tip: Change
LAN_NETWORKto match your local network. On Raspbian, runip route | grep defaultto find it (e.g.192.168.1.0/24).
docker compose up -d
Go to http://<YOUR-PI-IP>:8080 in a browser on the same network.
Default login: admin / adminadmin
ip route | grep default — if the output shows 192.168.1.1, your LAN_NETWORK is 192.168.1.0/24.id — use the uid and gid values shown (typically 1000 for the default pi user)./dev/net/tun doesn't exist, load the module: sudo modprobe tun. To make it persist across reboots, add tun to /etc/modules.docker run -d \
--privileged \
--device=/dev/net/tun \
-v /your/config/path:/config \
-v /your/downloads/path:/downloads \
-e "VPN_ENABLED=yes" \
-e "LAN_NETWORK=192.168.1.0/24" \
-e "NAME_SERVERS=1.1.1.1,9.9.9.9" \
-p 8080:8080 \
-p 8999:8999 \
-p 8999:8999/udp \
aiwi/docker-qbittorrentvpn
| Variable | Required | Default | Description |
|---|---|---|---|
VPN_ENABLED | No | yes | Enable VPN (yes or no) |
OPENVPN_USERNAME | No | — | VPN username (auto-configures .ovpn auth) |
OPENVPN_PASSWORD | No | — | VPN password (auto-configures .ovpn auth) |
LAN_NETWORK | Yes (if VPN on) | — | Local network in CIDR notation, e.g. 192.168.1.0/24 |
NAME_SERVERS | No | 1.1.1.1,9.9.9.9 | Comma-separated DNS servers |
PUID | No | 0 (root) | User ID for file ownership |
PGID | No | 0 (root) | Group ID for file ownership |
UMASK | No | 002 | File permission mask for new files |
WEBUI_PORT_ENV | No | 8080 | WebUI port (must also change exposed port to match) |
INCOMING_PORT_ENV | No | 8999 | Torrent listening port (must also change exposed port to match) |
| Path | Required | Description |
|---|---|---|
/config | Yes | qBittorrent config, OpenVPN config, and logs |
/downloads | No | Default download directory |
| Port | Protocol | Description |
|---|---|---|
8080 | TCP | qBittorrent WebUI |
8999 | TCP + UDP | qBittorrent incoming connections |
The container will not start if VPN_ENABLED=yes and no .ovpn file is found in /config/openvpn/.
.ovpn file from your VPN provider in /config/openvpn/.OPENVPN_USERNAME and OPENVPN_PASSWORD environment variables, orauth-user-pass credentials.conf to your .ovpn file and create /config/openvpn/credentials.conf:
your-username
your-password
Note: Only the first
.ovpnfile found is used. Multiple files won't create multiple connections.
Set WebUI\CSRFProtection=false in /config/qBittorrent/config/qBittorrent.conf if using a reverse proxy.
This happens when using port forwarding with bridge networking. Don't remap ports externally — instead change WEBUI_PORT_ENV and/or INCOMING_PORT_ENV and update the exposed ports to match.
/dev/net/tun exists: ls -la /dev/net/tunsudo modprobe tundocker compose logs -f qbittorrent.ovpn file works outside Docker firstdocker compose logs qbittorrent | grep -i openvpnLAN_NETWORK is set correctlyClone the repo and build:
git clone https://github.com/your-username/docker-qBittorrentvpn.git
cd docker-qBittorrentvpn
docker build -t qbittorrentvpn .
Then update docker-compose.yml to use image: qbittorrentvpn instead of image: aiwi/docker-qbittorrentvpn, or run directly:
docker run -d \
--privileged \
--device=/dev/net/tun \
-v /your/config/path:/config \
-v /your/downloads/path:/downloads \
-e "VPN_ENABLED=yes" \
-e "LAN_NETWORK=192.168.1.0/24" \
-e "NAME_SERVERS=1.1.1.1,9.9.9.9" \
-p 8080:8080 \
-p 8999:8999 \
-p 8999:8999/udp \
qbittorrentvpn
If you run into problems, open an issue on GitHub with:
docker compose logs qbittorrent)docker --version)uname -a)Content type
Image
Digest
sha256:4c06dd27f…
Size
105.5 MB
Last updated
2 months ago
docker pull aiwi/docker-qbittorrentvpn:a4c3c7db7a2aece32878822ee3866fb5ca458be1