-
Notifications
You must be signed in to change notification settings - Fork 54
Examples
Here are some working examples showing some ways in which the container can be used. If you've got an interesting use for the container, or have something that someone else might find useful, feel free to add it below.
Note that the socks-proxy
container essentially inherits the network stack of the vpn
container, so things like ports
are set on the vpn
container itself.
services:
vpn:
image: thrnz/docker-wireguard-pia
volumes:
- pia-dat:/pia
ports:
- 1080:1080
cap_add:
- NET_ADMIN
environment:
- LOCAL_NETWORK=192.168.1.0/24
- LOC=swiss
- USER=xxxx
- PASS=xxxx
sysctls:
- net.ipv4.conf.all.src_valid_mark=1
socks-proxy:
image: serjs/go-socks5-proxy
network_mode: "service:vpn"
volumes:
pia-dat:
Normally qBittorent would need the listen port to be manually set to the port number shown in the vpn
container's logs. This can be automated by scripting using the PORT_SCRIPT
env var. Note that access to the web ui port is exposed on the vpn
container itself, and that LOCAL_NETWORK
must be set correctly for access from other machines on the lan.
services:
vpn:
image: thrnz/docker-wireguard-pia
volumes:
- pia-dat:/pia
- /path/to/set_qbt_port.sh:/set_qbt_port.sh
ports:
- 8080:8080
cap_add:
- NET_ADMIN
environment:
- LOCAL_NETWORK=192.168.1.0/24
- LOC=swiss
- USER=xxxx
- PASS=xxxx
- PORT_FORWARDING=1
- PORT_SCRIPT=/set_qbt_port.sh
sysctls:
- net.ipv4.conf.all.src_valid_mark=1
qbittorrent:
image: lscr.io/linuxserver/qbittorrent:latest
network_mode: "service:vpn"
volumes:
- /path/to/appdata/config:/config
- /path/to/downloads:/downloads
volumes:
pia-dat:
The following script can be customized as needed then mounted inside the container and automatically run by setting the PORT_SCRIPT=/set_qbt_port.sh
env var. Ensure that the correct permissions are set first ( chmod +x /path/to/set_qbt_port.sh
).
#!/bin/bash
# The forwarded port is passed as the first argument to the script
port="$1"
QBT_USER="admin"
QBT_PASS="password"
QBT_PORT="8080"
echo "$(date): Setting qBittorrent listen port to $port..."
# Very basic retry logic so we don't fail if qBittorrent isn't running yet
while ! curl --silent --retry 10 --retry-delay 15 --max-time 10 \
--data-urlencode "username=${QBT_USER}" \
--data-urlencode "password=${QBT_PASS}" \
--output /dev/null \
--cookie-jar /tmp/qb-cookies.txt \
http://localhost:${QBT_PORT}/api/v2/auth/login
do
sleep 10
done
curl --silent --retry 10 --retry-delay 15 --max-time 10 \
--data 'json={"listen_port": "'"$port"'"}' \
--output /dev/null \
--cookie /tmp/qb-cookies.txt \
http://localhost:${QBT_PORT}/api/v2/app/setPreferences
# Check that the port was successfully updated
if [[ $(curl --silent --retry 10 --retry-delay 15 --max-time 10 --cookie /tmp/qb-cookies.txt \
http://localhost:${QBT_PORT}/api/v2/app/preferences | jq '.listen_port') = $port ]]; then
echo "$(date): qBittorrent listen port successfully set to $port"
else
echo "$(date): Error: qBittorrent port was not set"
See Issue #26 for a bit more info, including links to scripts for some other clients.
Another option is to use the PORT_FILE
env var. By default the container dumps the forwarded port number to /pia-shared/port.dat
which can then be mounted and monitored in other containers. Some 'helper' containers have been made for setting the listen port in qBittorrent, Transmission, and Deluge. For instance, the qBittorrent helper container example can be used as follows:
image: scotte/qbittorrent-porthelper:latest
container_name: qbittorrent-porthelper
environment:
- HOST=192.168.10.254:8080
- USERNAME=YourqBittorrentUsernameHere
- PASSWORD=YourqBittorrentPasswordHere
volumes:
- /data/software/wireguard-pia/:/piashared
depends_on:
- qbittorrent