Use VPN container as gateway

I have gluetun running in a container and I would like that container to serve as the gateway for other containers. Doing this in Portainer was easy, but I have since completely scraped portainer from my network. Now I’m not sure how to accomplish it in Docker.

Probably a setup like the one listed here may work for your case?
https://hub.docker.com/r/bubuntux/nordvpn
I copy below the docker compose you can find there as well

version: "3"
services:
  proxy:
    image: traefik:v2.4         # Review traefik documentation https://doc.traefik.io/traefik/ 
    container_name: traefik
    command:
      - --api.insecure=true
      - --providers.docker=true
      - --providers.docker.exposedbydefault=false
      - --entrypoints.web.address=:80
    ports:
      - 80:80
      - 8080:8080
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
    restart: unless-stopped
  vpn:
    image: ghcr.io/bubuntux/nordvpn
    container_name: vpn
    cap_add:
      - NET_ADMIN               # Required
      - NET_RAW                 # Required
    environment:                # Review https://github.com/bubuntux/nordvpn#environment-variables
      - TOKEN=f6f2bb45...       # Required
      - CONNECT=United_States
      - TECHNOLOGY=NordLynx
    sysctls:
      - net.ipv6.conf.all.disable_ipv6=1  # Recomended if using ipv4 only
  torrent:
    image: ghcr.io/linuxserver/qbittorrent
    network_mode: container:vpn
    labels:
      - traefik.enable=true
      - traefik.http.services.torrent.loadbalancer.server.port=8080
      - traefik.http.routers.torrent.rule=Host(`custom-host`)
    depends_on:
      - vpn
      
# Make sure that custom-host resolves to the ip address of the server 
# for example /etc/hosts contains 127.0.0.1  custom-host
# the torrent service would be available at http://custom-host

Yet another option is something like we-easy (link).

The important part is probably

sysctl="net.ipv4.ip_forward=1"

to enable IP routing.