Answers: <p>Docker actually manipulates <code>iptables</code> behind the scenes, so there is a good chance that <code>sshuttle</code> is interacting with docker in unpredictable ways.  Any rules that need to be added to IP Tables that affect the <code>docker</code> interface need to be added to the <code>DOCKER-USER</code> chain as per <a href="https://docs.docker.com/network/iptables/" rel="nofollow noreferrer">Docker and <code>iptables</code></a>.</p>
  
  <p>It's quite an involved topic so I would also consider reading <a href="https://success.docker.com/article/networking#iptables" rel="nofollow noreferrer">an exploration of Docker networking</a> and the <a href="https://docs.docker.com/network/" rel="nofollow noreferrer">overview of the docker network</a>.</p>
  
  <p>There is also an old <a href="https://stackoverflow.com/questions/29838892/how-to-let-docker-container-work-with-sshuttle">question on StackOverflow</a> but based upon the comments the current highest voted answer no longer works.</p>
  
Answers: CC BY-SA 4.0
Answers: 2019-10-21T11:18:49.793Z
Answers: 2019-10-21T11:18:49.793Z
Answers: Richard Slater
Body: <p>Well, the title says all. I have no success trying to route docker's network traffic through an active VPN connection (openconnect) or SSH tunnel (sshuttle). Docker creates a virtual network interface called <code>docker</code> which seems to be ignoring all the iptables rules that sshuttle adds. In VPN case however the entire docker process disconnects while OS's traffic is being routed through VPN.</p>
  
  <p>Please note that I am not trying to push a contained behind VPN. The problem occurs specifically on build stage. </p>
  
Tags: <docker>
Title: Tunnel docker traffic though VPN or SSH, during build stage
UserDisplayName: Soroush Rabiei
ThreadText: # Tunnel docker traffic though VPN or SSH, during build stage
  
  (Asked by: username_0 on 2019-10-21)
  
  Well, the title says all. I have no success trying to route docker's network traffic through an active VPN connection (openconnect) or SSH tunnel (sshuttle). Docker creates a virtual network interface called `docker` which seems to be ignoring all the iptables rules that sshuttle adds. In VPN case however the entire docker process disconnects while OS's traffic is being routed through VPN.
  
  Please note that I am not trying to push a contained behind VPN. The problem occurs specifically on build stage.
  
  **Tags:** docker
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2019-10-21. Score: 1
  
  Docker actually manipulates `iptables` behind the scenes, so there is a good chance that `sshuttle` is interacting with docker in unpredictable ways. Any rules that need to be added to IP Tables that affect the `docker` interface need to be added to the `DOCKER-USER` chain as per [Docker and `iptables`](https://docs.docker.com/network/iptables/).
  
  It's quite an involved topic so I would also consider reading [an exploration of Docker networking](https://success.docker.com/article/networking#iptables) and the [overview of the docker network](https://docs.docker.com/network/).
  
  There is also an old [question on StackOverflow](https://stackoverflow.com/questions/29838892/how-to-let-docker-container-work-with-sshuttle) but based upon the comments the current highest voted answer no longer works.
  
  
  ---
  
  