Service links or not?

Hi,
This is probably a naive question but I wonder why there is the possibility to explicitely link services ?

I have a stack with 2 services : ServiceFrom and serviceTo. ServiceFrom is the entry point and it internally calls ServiceTo over http like this : GET http://serviceto/hello

This work perfectly because the DNS resolution does its job well.

But, when I added ServiceFrom and ServiceTo in my stack I left the “service links” section blank. So I wondered in which case it was interresting to use these links?

Thank you for your help

I generally default to using them for 2 reasons:

  1. if you specify the link, then the in Rancher if you select View Graph on a stack, then there will be a line drawn between the services indicating that one is a dependency of the other. If you don’t specify the link, then this line is not drawn even though it may be a dependency
  2. Specifying the link makes the resulting docker-compose.yml portable to a local non-Rancher system. This means I could use the same file to start the stack locally on native Docker using docker-compose and the networking will work. If the link wasn’t specified, then the networking would not work since Rancher’s DNS system doesn’t exist locally.

They also allow you to ‘alias’ a dependency, so that your image only needs to know that it will find it’s database by resolving db, not that this stack should have it’s database provided by the mysql-db-07-01 service.

And we may eventually add options to allow restricting inter-container communication (more than anybody in the environment can talk to anybody else). Links would provide the declaration of what dependencies there are and what communication flows should be allowed.