Docker Community Forums

Share and learn in the Docker community.

Ipaddress of containers scaled by docker-compose

Following the example of docker-compose where there are web and load balancer containers

load balancer service name is LB and web service name is WEB

everything is working fine.

My question here is when I scale web using the command

docker-compose scale web=5

It starts 5 instances of the web service.
Is it possible for these instances to know the ip address of other instances started before them so that they can talk to each other for some configuration changes.
If yes, How and If no, what is the work around since my webapp should know the ipaddresses of all other nodes to work out some configuration details.

Thanks
Harneet

@friism can you help me on this please.

Regards,
Harneet

The containers will be able to contact one another using the web hostname: https://docs.docker.com/engine/userguide/networking/configure-dns/

I don’t think it’s advisable (because containers will be started and stopped continiously), but you can also query the Docker engine API for IP addresses: http://stackoverflow.com/a/20686101/2942