Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ping docker containers on different hosts with ip addresses

I want to ping a docker container on Host A (EC2 instance) from another docker container on Host B (another EC2 instance). What are the steps I need to follow?

like image 270
user1016313 Avatar asked Dec 03 '25 09:12

user1016313


1 Answers

One option is an Overlay Network such as weave. This is very easy to set up, lets containers talk to each other on different hosts or even different datacenters, and lets you choose what to connect and what to isolate. Please note: I work on weave.

Why might you need an add-on? As described in the docs, by default Docker creates a single-host bridge and gives each container a private IP address. So now you have two problems: how to set up routes between bridges on different machines, and how to hide or change those IP addresses because they can't be used on the public internet.

You could just use the host's network, with the docker run command-line option --net=host, but this loses some of the encapsulation you get from containers.

There are active discussions going on about Docker network drivers which would make solutions easier to implement, but no code as yet.

Amazon have launched their own container clustering service which promises to let containers talk to each other, but again it's not available yet.

like image 134
Bryan Avatar answered Dec 05 '25 02:12

Bryan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!