Skip to content

Use docker compose

Jason Lyu edited this page Feb 11, 2021 · 5 revisions

Example

docker-compose.yml

version: '2.4'

services:
  tun2socks:
    image: ghcr.io/xjasonlyu/tun2socks:latest
    cap_add:
      - NET_ADMIN
    devices:
        - '/dev/net/tun:/dev/net/tun'
    environment:
      - LOGLEVEL=info             # default
      - TUN=tun0                  # default
      - ADDR=198.18.0.1/15        # default
      - MTU=9000                  # default
      - PROXY=                    # *required
      - STATS=:8080               # optional
      - TOKEN=                    # optional
      - EXTRA_COMMANDS=           # optional
      - TUN_INCLUDED_ROUTES=      # optional
      - TUN_EXCLUDED_ROUTES=      # optional
      # - GODEBUG=madvdontneed=1  # optional
    networks:
      switch:
        ipv4_address: 172.20.1.2
    sysctls:
      - net.ipv4.ip_forward=1
      - net.ipv4.conf.all.rp_filter=0
    restart: unless-stopped
    container_name: tun2socks

networks:
  switch:
    name: switch
    ipam:
      driver: default
      config:
        - subnet: '172.20.1.0/25'
          gateway: 172.20.1.1
    driver: macvlan
    driver_opts:
      parent: eth0

Start

docker-compose up -d
Clone this wiki locally