When the world says, ‘Give up,’ hope whispers, ‘Try it one more time’, Lyndon B. Johnson
A VPN is an encrypted connection that allows your device to communicate over the internet through a secure server. When connected to a VPN, your internet traffic is routed through a VPN server, effectively masking your device’s IP address and location. By utilizing a VPN, you will gain some benefits:
Before configuring Docker and the VPN containers, make sure you have an Ubuntu Server set up (this could be a physical home server, a VM, or an LXC container running Ubuntu), say a container (e.g., 301 Ubuntu-Desktop).
sudo apt update && sudo apt upgrade -y
Docker allows us to run applications in isolated containers.
sudo apt update # Update Package List
apt install curl
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
# Manage Docker as a non-root user
adduser nmaximo7
sudo usermod -aG sudo nmaximo7
su nmaximo7
sudo usermod -aG docker $USER # Add your user to the docker group.
newgrp docker
nmaximo7@ubuntu-desktop:/root$ id
uid=1000(nmaximo7) gid=110(docker) groups=110(docker),27(sudo),100(users),1000(nmaximo7)
# Create the volume that Portainer Server will use to store its database:
docker volume create portainer_data
# Download and install the Portainer Server container:
docker run -d -p 8000:8000 -p 9443:9443 --name portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:sts
Now that the installation is complete, you can log into your Portainer Server instance by opening a web browser and going to: [https:] // localhost:9443, e.g., [https:] // 192.168.1.52:9443
# Troubleshooting:
# Your Portainer instance timed out for security purposes. To re-enable your Portainer instance, you will need to restart Portainer.
docker restart portainer
version: '3.9'
services:
gluetun:
image: qmcgaw/gluetun
container_name: gluetun
cap_add:
- NET_ADMIN
devices:
- /dev/net/tun:/dev/net/tun
ports:
- 8080:8080 # qbittorrent web interface
- 6881:6881 # qbittorrent torrent port
- 6789:6789 # nzbget
- 9696:9696 # prowlarr
volumes:
- /docker/gluetun:/gluetun
environment:
- VPN_SERVICE_PROVIDER=airvpn
- VPN_TYPE=wireguard
- FIREWALL_VPN_INPUT_PORTS=port
# - FIREWALL_OUTBOUND_SUBNETS=192.168.0.0/24 # add if prowlarr wont connect to other arr apps, change to your specific subnet
- WIREGUARD_PRIVATE_KEY=key
- WIREGUARD_PRESHARED_KEY=key
- WIREGUARD_ADDRESSES=ip
- SERVER_COUNTRIES=country
- SERVER_CITIES=city
- HEALTH_VPN_DURATION_INITIAL=120s
healthcheck:
test: ping -c 1 www.google.com || exit 1
interval: 60s
timeout: 20s
retries: 5
restart: unless-stopped
# This is a new addition since creating the tutorial video on this stack.
# See the 'qBittorrent Stalls with VPN Timeout' section for more information.
deunhealth:
image: qmcgaw/deunhealth
container_name: deunhealth
network_mode: "none"
environment:
- LOG_LEVEL=info
- HEALTH_SERVER_ADDRESS=127.0.0.1:9999
- TZ=America/Los_Angeles
restart: always
volumes:
- /var/run/docker.sock:/var/run/docker.sock
# Healthcheck was added to work with deunhealth to restart container
# on unhealthy status. labels allows deunhealth to monitor.
qbittorrent:
image: lscr.io/linuxserver/qbittorrent:latest
container_name: qbittorrent
restart: unless-stopped
labels:
- deunhealth.restart.on.unhealthy= "true"
environment:
- PUID=1000
- PGID=1000
- TZ=America/Los_Angeles
- WEBUI_PORT=8080
- TORRENTING_PORT=6881
volumes:
- /docker/qbittorrent:/config
- /data:/data
network_mode: service:gluetun
healthcheck:
test: ping -c 1 www.google.com || exit 1
interval: 60s
retries: 3
start_period: 20s
timeout: 10s