title: How do I prevent redirected docker ports from being open to the outside world?
body: <p>I have several web services in different containers and I redirected 80 ports of each server to another port on the host server. (container 1 80 -> 8003, container 2 80 -> 8004, container 3 80 -> 8005) I want to prevent access to these ports except the preconfigured ip list </p>
  
  <p>I've added iptables rules to the "docker-user" chain as follows;</p>
  
  <pre><code>-A INPUT -s 212.154.74.194/32 -p tcp -j ACCEPT //accept all from this ip
  -A INPUT -s 185.22.208.0/25 -p tcp -j ACCEPT //accept all from this ip
  -A INPUT -p tcp -m tcp --dport 8003 -j DROP //block anyone except allowed ips 
  -A INPUT -p tcp -m tcp --dport 8004 -j DROP //block anyone except allowed ips
  -A INPUT -p tcp -m tcp --dport 8005 -j DROP //block anyone except allowed ips
  </code></pre>
  
  <p>But it doesn't work. Routed ports can still be accessed from the outside. I don't know what I did wrong. How can I block access to routed ports?</p>