Skip to content

Instantly share code, notes, and snippets.

@thermatk
Created September 14, 2022 17:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thermatk/1ad9a0e3be026c8a8c4db227bc0b80f0 to your computer and use it in GitHub Desktop.
Save thermatk/1ad9a0e3be026c8a8c4db227bc0b80f0 to your computer and use it in GitHub Desktop.
Containerized VPN + torrents

Setting up Transmission with VPN-only exit

Install Docker and Docker Compose

Arch

sudo pacman -S docker
sudo systemctl enable docker.service
sudo systemctl start docker.service
sudo pacman -S docker-compose

Ubuntu

Guide link: https://docs.docker.com/engine/install/ubuntu/

sudo apt update
sudo apt install -y ca-certificates curl gnupg lsb-release

sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg

echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null


sudo apt install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin

Configure the containers

Create a folder for all files, e.g.:

mkdir -p ~/dockerfun/

docker-compose.yml

Create a docker-compose.yml

gedit ~/dockerfun/docker-compose.yml

with contents

version: "3"
services:
  gluetun:
    image: qmcgaw/gluetun
    container_name: gluetun
    cap_add:
      - NET_ADMIN
    volumes:
      - ${DOCKERCONFDIR}/gluetun:/gluetun
    ports:
    # transmission ui
      - 9091:9091
    # gluetun control server
    # https://github.com/qdm12/gluetun/wiki/HTTP-control-server
      - 8000:8000/tcp
    environment:
      - PGID=${PGID}
      - PUID=${PUID}
      ### VPN Settings start
      - VPN_SERVICE_PROVIDER=REDACTED
      - VPN_TYPE=wireguard
      - VPN_INTERFACE=REDACTED
      - WIREGUARD_PRIVATE_KEY=${WIREGUARD_PK}
      - WIREGUARD_ADDRESSES=REDACTED
      - SERVER_COUNTRIES=REDACTED
      ### VPN Settings end
      # subnets access
      #- FIREWALL_OUTBOUND_SUBNETS=192.168.0.0/24
      - TZ=${TZ}
    restart: unless-stopped
  transmission:
    image: linuxserver/transmission
    container_name: transmission
    network_mode: 'service:gluetun'
    depends_on:
      - gluetun
    environment:
      - PGID=${PGID}
      - PUID=${PUID}
      - TZ=${TZ}
      # Specify an alternative UI
      # options are /combustion-release/, /transmission-web-control/, /kettu/, /flood-for-transmission/, and /transmissionic/
      - TRANSMISSION_WEB_HOME=/flood-for-transmission/
    volumes:
      - ${DOCKERCONFDIR}/transmission/config:/config
      - ${DOCKERCONFDIR}/transmission/downloads:/downloads
      - ${DOCKERCONFDIR}/transmission/watch:/watch
    restart: unless-stopped

Adjust the VPN Settings for your provider, for example a custom WireGuard:

https://github.com/qdm12/gluetun/wiki/Custom-provider

Port forwarding

Adjust the VPN settings for port forwarding, if available on your provider:

https://github.com/qdm12/gluetun/wiki/VPN-server-port-forwarding

Additionally, adjust Transmission config in such a case.

Transmission UI

Pick your favorite UI for web access by overriding TRANSMISSION_WEB_HOME:

Or maybe you prefer one of the remote apps:

Env variables

Create the .env

gedit ~/dockerfun/.env

with contents

DOCKERCONFDIR='/home/REDACTED/dockerfun'
PGID='REDACTED'
PUID='REDACTED'
TZ='Europe/Berlin'
WIREGUARD_PK='REDACTED'

Adjust the PUID/PGID (look up using id command), the full path to the created configuration folder (e.g. /home/myuser/dockerfun). Adjust variables for your VPN settings, if not done directly in yaml.

Start Docker Compose

cd ~/dockerfun/
sudo docker compose up -d

To see logs:

sudo docker compose logs -f

To test external ip of the gluetun container:

sudo docker run --rm --network=container:gluetun alpine:3.14 sh -c "apk add wget && wget -qO - http://ipwho.is/"

Compare to host:

wget -qO - http://ipwho.is/

Usage

Open the Transmission UI in browser:

http://localhost:9091

or connect one of the remote apps.

To start downloading, add a torrent/magnet through the interface or just save a torrent file in the ~/dockerfun/transmission/watch folder to be picked up automatically.

The downloaded files will be under ~/dockerfun/transmission/downloads.

Stop the containers

sudo docker compose down
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment