Linking containers

When you're running distributed applications, you have to connect different services in order to make them work together. To achieve this requirement, you need to know the hostnames or IP addresses of the services, among other configuration variables. The order in which the services are made available is also important. Let's consider the following simple application:

Services dependencies

The preceding diagram represents the most simple application; it has only one dependency on a database server. In this example, the application needs some database configuration parameters, such as the IP address, port, and so on. And of course, the database service should be available before starting the application; otherwise, the application won't be able to start.

In order to solve this simple requirement, you can use the following two options as part of your docker-compose.yaml file:

  • links
  • depends_on
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.143.205.27