Docker Compose: A Mini Orchestration Tool for Local Development
55%
Managing Service Dependencies
In the previous example, we have two services: db and wordpress. The wordpress service, in reality, depends on the db service. This means that the wordpress service cannot start until the db service is up and running. If we start the wordpress service without starting the db service, we will get an error.
Therefore, we need to start the db service first, then start the wordpress service. In Docker Compose, we can do this using the depends_on option:
services:
db:
image: mysql:9.6.0
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: mypassword
MYSQL_DATABASE: wordpress
MYSQL_USER: user
MYSQL_PASSWORD:Painless Docker - 2nd Edition
A Comprehensive Guide to Mastering Docker and its EcosystemEnroll now to unlock all content and receive all future updates for free.
Unlock now  $31.99$25.59Learn More
Hurry! This limited time offer ends in:
To redeem this offer, copy the coupon code below and apply it at checkout:
