What is the recommended way to connect app to db in rancher?

Hi,

Lately, I have been wondering what are the different ways to connect an app to db in rancher.

Assume we have a mysql db container running. Now assume an app is running inside an app container.

Traditionally, we have to provide connection string, so that the app can connect to database.

In docker, we link app and db container using --link and use ALIAS_PORT environment variable as connection string and make the app to connect to db.

I have been thinking since rancher services have dns entry serivce.stack.rancher.internal, can we use this as connection string for app?

Or is their any better way to handle connection strings?.

What are the methods you guys use?

Thank you

Short answer: Make a Stack, each container (DB + APP) is a service. Each service has the Service Links. Once a service is active, you can link it to other services.

http://docs.rancher.com/rancher/latest/en/cattle/adding-services/