Docker Community Forums

Share and learn in the Docker community.

How to bind containers to specific network interfaces on AWS?


(Brayn) #1


What I want to do is be able to launch containers that would be bound on a specific IP address and furthermore, requests made from the container should appear to be originating from that IP address.

I have an EC2 instance on AWS that has two network interfaces attached, each interface with multiple secondary IP addresses attached as such:
main_private_ip -> main_public_ip
secondary_private_ip -> secondary_public_ip

main_private_ip -> main_public_ip
secondary_private_ip -> secondary_public_ip

If I start a container using -p with eth0_main_private_ip:port:port all works fine.

If I start a container using eth0_secondary_private_ip:port:port I can access the container on eth0_secondary_public_ip but requests appear to be originating from eth0_main_public_ip

If I start a container using eth1_main_private_ip then eth1_main_public_ip returns a timeout.

I am guessing that this is related to the default bridge configuration but am not sure how to fix it.