Why would you want to add containers dynamicly? On standalone docker --link takes care of this. On docker-compose and Swarm the docker networks dns-server takes care of this - the servicename is registered as hostname and can be used from other containers to access it.
@meyay thanks for your response…in my case i will be running three docker containers, i know which ip address it will take by default (172.17.0.* etc). i want to update those ip with hostname in /etc/hosts becoz i want them communicate without password.
see im using container as a OS (centos7) i want all my containers should communicate wit each other becoz im going to deploy my app over there for that i need all instance to b communicate without password. everythng has set but the only problem is i need to add ip and hostname manually, this is what im trying to avoide…thanks
What I wrote above works with single and/or multi host multi container deployments. So what makes your scenario so special that the generaly working approach does not apply for you?!
You neither explained the password situation, nor why this relates to centos7.