title: port forwarding using iptables inside docker container
body: <p>I am running two services (A &amp; B) on one container. One service mocks a dependency that is required by the other.</p>
  
  <p>Service A is a black-box and makes a call to an IP 169.254.169.254. I want to forward that call using iptables to Service B.</p>
  
  <p>I am starting the container like this so it can have its own iptables,</p>
  
  <pre><code>docker run -it --cap-add=NET_ADMIN --sysctl net.ipv4.conf.eth0.route_localnet=1 &lt;name&gt; bash
  </code></pre>
  
  <p>Once in bash, i configure iptables to forward the call,</p>
  
  <pre><code>iptables -t nat -I PREROUTING -p tcp -d 169.254.169.254 --dport 80 -j DNAT --to-destination "127.0.0.1:8099" -i eth0
  </code></pre>
  
  <p>However the call doesn't get routed to 127.0.0.1. The same set of steps work if done in a Ubuntu Xenial VM.</p>