title: How to tunnel TCP traffic over ssh from a docker container?
body: <p><strong>Here is my situation:</strong>
  I have an application running locally at home in a docker container, based on lambci/lambda:build-nodejs8.10. The application sends https requests to a remote server on two urls. The remote server, however, only accepts requests from IPs coming from my office network. I can use VPN to connect to the office network but it's not configured to give me a route onto the internet only accessing machines on the network. What I can do is ssh into machines on the office network, which do have internet access.</p>
  <p><strong>Attempts at solution and previous solution:</strong>
  Before I've only had to send requests to one URL, say remote1.com. I've solved this by forwarding ports over ssh, like so:</p>
  <ol>
  <li><p>Connect to VPN on my local machine</p>
  </li>
  <li><p>Start the docker container in interactive mode with a bash shell</p>
  </li>
  <li><p>redirect traffic for remote1.com to localhost:</p>
  <p><code>echo &quot;127.0.0.1 remote1.com&quot; &gt;&gt; /etc/hosts</code></p>
  </li>
  <li><p>forward traffic to 127.0.0.1:443 to office.machine.com over ssh:</p>
  <p><code>ssh user@office.machine.com -L 443:remote1.com:443</code></p>
  </li>
  <li><p>Connect to the docker container from a new terminal and start the application.</p>
  </li>
  </ol>
  <p>This works very well for just one remote url. Trying do step 2-4 twice won't work as the port is already forwarded.</p>
  <p>I've tried running sshuttle on the docker-container. Installing it works fine (through cloning the git repo):</p>
  <pre><code>git clone https://github.com/sshuttle/sshuttle.git
  cd sshuttle
  sudo ./setup.py install
  </code></pre>
  <p>but running it results in the following error:</p>
  <pre><code>iptables v1.4.18: can't initialize iptables table `nat': Permission denied (you must be root)
  Perhaps iptables or your kernel needs to be upgraded.
  firewall manager: undoing changes.
  firewall manager: undoing IPv4 changes.
  iptables v1.4.18: can't initialize iptables table `nat': Permission denied (you must be root)
  Perhaps iptables or your kernel needs to be upgraded.
  firewall manager: Error trying to undo IPv4 firewall.
  firewall manager: ---&gt; Traceback (most recent call last):
  firewall manager: ---&gt;   File &quot;/usr/local/lib/python2.7/site-packages/sshuttle-0.78.5.dev10+g561b648-py2.7.egg/sshuttle/firewall.py&quot;, line 270, in main
  firewall manager: ---&gt;     method.restore_firewall(port_v4, socket.AF_INET, udp, user)
  firewall manager: ---&gt;   File &quot;/usr/local/lib/python2.7/site-packages/sshuttle-0.78.5.dev10+g561b648-py2.7.egg/sshuttle/methods/nat.py&quot;, line 99, in restore_firewall
  firewall manager: ---&gt;     if ipt_chain_exists(family, table, chain):
  firewall manager: ---&gt;   File &quot;/usr/local/lib/python2.7/site-packages/sshuttle-0.78.5.dev10+g561b648-py2.7.egg/sshuttle/linux.py&quot;, line 33, in ipt_chain_exists
  firewall manager: ---&gt;     raise Fatal('%r returned %d' % (argv, rv))
  firewall manager: ---&gt; Fatal: ['iptables', '-t', 'nat', '-nL'] returned 3
  firewall manager: undoing /etc/hosts changes.
  firewall manager: Error trying to undo /etc/hosts changes.
  firewall manager: ---&gt; Traceback (most recent call last):
  firewall manager: ---&gt;   File &quot;/usr/local/lib/python2.7/site-packages/sshuttle-0.78.5.dev10+g561b648-py2.7.egg/sshuttle/firewall.py&quot;, line 282, in main
  firewall manager: ---&gt;     restore_etc_hosts(port_v6 or port_v4)
  firewall manager: ---&gt;   File &quot;/usr/local/lib/python2.7/site-packages/sshuttle-0.78.5.dev10+g561b648-py2.7.egg/sshuttle/firewall.py&quot;, line 51, in restore_etc_hosts
  firewall manager: ---&gt;     rewrite_etc_hosts({}, port)
  firewall manager: ---&gt;   File &quot;/usr/local/lib/python2.7/site-packages/sshuttle-0.78.5.dev10+g561b648-py2.7.egg/sshuttle/firewall.py&quot;, line 30, in rewrite_etc_hosts
  firewall manager: ---&gt;     os.link(HOSTSFILE, BAKFILE)
  firewall manager: ---&gt; OSError: [Errno 18] Invalid cross-device link
  fatal: ['iptables', '-t', 'nat', '-nL'] returned 3
  c : fatal: cleanup: ['/usr/bin/python', '/usr/local/bin/sshuttle', '-v', '-v', '--method', 'auto', '--firewall'] returned 99
   s:   Ready: 1 r=[4] w=[] x=[]
  </code></pre>
  <p><strong>What I can and cannot do:</strong></p>
  <p>Can:</p>
  <ul>
  <li>Install software and change configurations on my local PC (Win/Ubuntu)</li>
  <li>Install software on the docker-image (not all packages are available by default though)</li>
  </ul>
  <p>Cannot:</p>
  <ul>
  <li>Change configuration or install software on the remote or office server</li>
  </ul>
  <p>Is there a way of running all (or all HTTPS request to the two specific urls) TCP traffic from the application running in the docker container through the office computer over ssh?</p>