From the course: Learning Docker Compose

Unlock the full course today

Join today to access over 24,600 courses taught by industry experts.

Enforcing start-up order

Enforcing start-up order - Docker Tutorial

From the course: Learning Docker Compose

Enforcing start-up order

- [Instructor] Many common application architectures have service dependencies, meaning one service cannot operate without another. In the case of Kinetico's Storefront application, it may require that the database exists for the application to work as intended. To run the application container, we need to make sure that the database container is running first. This can be done manually with regular Docker commands, but Compose provides utilities to enforce startup order automatically using the depends on flag. Under a service definition in the Docker composed YAML file, Ada depends on object. Nested underneath it are service names in list format. In this example, that would be database. Now that this dependency relationship has been established, compose will start and stop services in dependency order. Docker-compose up will start the database before it starts storefront. And Docker-compose down will stop storefront…

Contents