You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When Docker Compose runs, it creates a virtual network[^1] which allows you to connect to `db`, which connects to the running `db` service container.
49
54
:::
50
55
56
+
In the `docker-compose.yml` file above you can also see that the `web` service depends on the `db` service, with the condition that it is healthy. A service is deemed "healthy" when its healthcheck passes.
57
+
58
+
We've added a healthcheck to the `db` service which runs the `pg_isready`[^2] program using the supplied database and PostgreSQL user. This just tells us whether the PostgreSQL server is ready to respond to requests.
59
+
60
+
Adding this means the `web` service won't start until the `db` service is ready to respond to requests.
61
+
51
62
## Named volumes in Docker Compose
52
63
53
64
You'll notice that our `docker-compose.yml` file has these lines:
@@ -113,4 +124,5 @@ Note you must be in the folder that contains your `docker-compose.yml` file in o
113
124
Running `docker compose down` will **not** delete your named volumes. You need to use the `-v` flag for that. Deleting the named volumes deletes the data in them irreversibly.
114
125
:::
115
126
116
-
[^1]: [Networking in Compose (official docs)](https://docs.docker.com/compose/networking/)
127
+
[^1]: [Networking in Compose (official docs)](https://docs.docker.com/compose/networking/)
0 commit comments