8

I have an ubuntu server running docker with one container. My server ip address is 172.31.12.29/20 in my vpc. It has tow bridges (docker0 ans lxcbr0).

My container ip address is 172.17.0.2/16.

The host and the container can ping themselves.

I have another server in my vpc with 172.31.1.233/20 for ip address. I just want my to reach my containers from this server but I don't know how to do this.

My two servers can ping themselves to.

I try to do this configuring my vpc routes table to route 172.17.0.0/16 targeted requests to 172.31.12.29 but it doesn't work.

Any idea ?

5

It sounds like you also need to disable Source/Destination IP Check on the instance hosting the containers (and you need the static route in the VPC route table, pointing to that instance by id). VPC network infrastructure drops IP traffic with IP addresses that don't make sense based on what the infrastructure knows internally about IP addresses associated with each instance. This setting changes that functionality on instances where you apply it. If you have a NAT instance, you'll notice this is already done for that instance, otherwise it wouldn't be able to route external traffic to/from other instances.

http://docs.aws.amazon.com/AWSEC2/latest/CommandLineReference/ApiReference-cmd-ModifyInstanceAttribute.html

This is also on Instance Actions in the console.

0

You can expose the container port (docker run -p 1234:1234) and connect to your ec2 instances address (10.x.y.z:1234)

To avoid hardcoding addresses on the consumer side, you can use the ambassador pattern: https://docs.docker.com/engine/admin/ambassador_pattern_linking/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.