Route container traffic through Wireguard VPN

nano docker-compose.yaml
version: "3.8"
services:
  wireguardclient:
    image: ghcr.io/linuxserver/wireguard:latest
    container_name: wireguardclient
    cap_add:
      - NET_ADMIN
      # - SYS_MODULE
    environment:
      - TZ=UTC
      # - PUID=7722
      # - PGID=7722
    restart: "unless-stopped"
    sysctls:
      - net.ipv4.conf.all.src_valid_mark=1
      - net.ipv6.conf.default.disable_ipv6=1
    volumes:
      - /usr/share/zoneinfo/UTC:/etc/localtime:ro
      - ./wg0.conf:/config/wg0.conf
      - /lib/modules:/lib/modules
  web:
    image: nginx
    container_name: nginx
    network_mode: "service:wireguardclient"  # <-- important bit, don't forget
    volumes:
    - ./templates:/etc/nginx/templates
    environment:
    - NGINX_HOST=foobar.com
    - NGINX_PORT=56396
  # ubuntu:
  #   image: ubuntu:22.04
  #   command: tail -f /dev/null
  #   container_name: ubuntu
  #   network_mode: "service:gluetun"  # <-- important bit, don't forget
  #   restart: unless-stopped


#docker exec -it nginx /bin/bash
#docker exec -it ubuntu /bin/bash
#docker exec -it wireguardclient /bin/bash
# apt update
#apt install net-tools curl wget nload htop iputils-ping -y

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *