Running docker in VPC and accessing container from another VPC machine
- by Bogdan Gaza
I'm having issues while running docker in AWS VPC.
Here is my setup:
I've got two machines running in VPC:
10.0.100.150
10.0.100.151
both having an elastic IPs assigned to them, both running in the same internet enabled subnet.
Let's say I'm running a web server that serves static files in a container on the 10.0.100.150 machine the container:
IP: 172.17.0.2
port 8111 is forwarded on the 8111 port on the machine.
I'm trying to access the static files from my local machine (or another non-VPC machine also tried an EC2 instance not running in the VPC) and it work flawlessly.
If I try to access the files from the other machine (10.0.100.151) it hangs. I'm using wget to pull the files.
Tried to debug it with tcpdump and ngrep and that I have seen is that the request reaches the container. If I ngrep on the host machine I see the requests going in but no response going back. If I ngrep on the container I see the requests going in and the response going back.
I've tried multiple iptables setups (with postrouting enabled, with manually forwarding ports etc) but no success.
Help in any way - even debugging directions would be much appreciated.
Thanks!