Routing WSL2 and Docker through the proxy

WSL2 and Docker containers sit on their own networks and have no idea a proxy is running on the host, so apt, pip and docker pull keep timing out. Either tell them the proxy address explicitly, or take the whole machine over with TUN mode.

Option 1: TUN mode, the easy way

  1. Turn on TUN mode in Clash Verge — setup is covered in the TUN mode guide.
  2. Turn on Allow LAN as well, otherwise traffic from containers and WSL is not picked up.
  3. Run curl -I https://www.google.com inside WSL to confirm it now goes through.
Sponsored Where does the subscription link come from? Our partner provider gives you 1 GB of high-speed Hong Kong data at signup — import it in one click. Get high-speed nodes

Option 2: point them at the proxy by hand

  1. Enable Allow LAN in Clash Verge settings so the mixed port accepts outside connections — see Sharing the proxy on your LAN.
  2. Find the host address from inside WSL2: the nameserver line in cat /etc/resolv.conf. With mirrored networking enabled, use 127.0.0.1 directly.
  3. Append export http_proxy=http://HOST_ADDRESS:7897 and export https_proxy=$http_proxy to ~/.bashrc, then run source ~/.bashrc.
  4. Docker pulls images through its daemon, not your shell, so environment variables do nothing for it. In Docker Desktop, set the same address under Settings, Resources, Proxies.