1
0
mirror of https://github.com/kamranahmedse/developer-roadmap.git synced 2025-08-24 09:55:57 +02:00

Merge pull request #5008 from TaviotBaptiste/patch-2

Add depends_on to dockerfile example
This commit is contained in:
dsh
2024-05-10 09:43:56 +01:00
committed by GitHub

View File

@@ -21,13 +21,15 @@ services:
image: nginx:latest image: nginx:latest
ports: ports:
- "80:80" - "80:80"
depends_on:
- db
db: db:
image: mysql:latest image: mysql:latest
environment: environment:
MYSQL_ROOT_PASSWORD: mysecretpassword MYSQL_ROOT_PASSWORD: mysecretpassword
``` ```
In this example, we have specified two services: a web server (`web`) running the latest version of the nginx image, and a database server (`db`) running MySQL. The web server exposes its port 80 to the host machine, and the database server has an environment variable set for the root password. In this example, we have specified two services: a web server (`web`) running the latest version of the nginx image, and a database server (`db`) running MySQL. The web server exposes its port 80 to the host machine and depends on the launch of the database (`db`). The database server has an environment variable set for the root password.
## Running Docker Compose: ## Running Docker Compose: