How can I get name resolution for linked services behind a load balancer?

I’m playing around with rancher as a platform for hosting multiple cms app containers. There’s one thing I just don’t get right:

I’m using a rather simple stack with an application container linked to a database container, referring the database as ‘db’, and using a load balancer to point my external domain to the application container, as in this image:

When it comes to configurig my app to enter the database credentials, I’m able to use the db container using it’s internal IP address, but I’m not able to use the given service name ‘db’. When I open a shell inside the app container and do something like ‘ping db’, it won’t resolve.

FYI, rancher server and agent are running on the same host.

So what am I missing? I’d like to use a kind of hostname for the database service, as the internal IP might change.

Thx a lot,
Boris

Can you provide the docker-compose.yml file? Just to confirm, you can ping the container IP when inside the app container, but you are unable to ping db?

Do you have more than 1 host? Can you also check that if your agent is on the same machine as your server that the IP address on the Hosts screen is the right IP? You want to make sure it didn’t pick up the docker IP, which usually starts with 172.17.x.x. If it has the wrong IP, you need to follow the instructions on how to set the IP of the agent correctly, http://docs.rancher.com/rancher/rancher-ui/infrastructure/hosts/custom/#samehost.

Finally, what version are you running?