|
Answer» Docker-compose does not wait for any container to be “READY” before going ahead with the next containers. In order to achieve the order of EXECUTION, we can use: - The “depends_on” which got added in version 2 of docker-compose can be used as shown in a sample docker-compose.yml FILE below:
version: "2.4"services: backend: build: . depends_on: - db db: image: postgresThe introduction of service dependencies has various causes and EFFECTS: - The docker-compose up command starts and runs the services in the dependency order specified. For the above example, the DB container is started before the backend.
- docker-compose up SERVICE_NAME by default includes the dependencies associated with the service. In the GIVEN example, running docker-compose up backend creates and starts DB (dependency of backend).
- Finally, the command docker-compose stop also stops the services in the order of the dependency specified. For the given example, the backend service is stopped before the DB service.
|