I am trying to use
iptables to manually reconstruct what
-p hport:cport does, as a learning exercise. Concretely, I have a container running on 172.17.0.2:8082. I did not do
-p 8082:8082. I am using Docker 1.12.1 on Ubuntu 16.04.1 if that clarifies anything.
sudo iptables -t nat -A DOCKER -p tcp --dport 8082 -j DNAT --to-destination 172.17.0.2:8082
That seems to match similar rules created by Docker. There is also a POSTROUTING rule that is added, which I have not been able to decipher. Can someone point to a tutorial or explain the steps? Again this is for learning, I understand restarting the container is the way to go with the appropriate port mappings.
At a high level, I want
curl localhost:8082 to respond, just like it would have if I had done