The API Raced Postgres and Crashed — Docker Compose Explained

Опубликовано: 31 Июль 2026
на канале: TheCodeForge
25
0

The API container exited within 10 seconds with ECONNREFUSED because Postgres wasn't ready — `depends_on` only waits for the container to start, not for the service to accept connections. This is Docker Compose done right: services, networks, volumes, env, profiles, and proper healthcheck-gated startup ordering.

⏳ Timestamps:
0:00 - Cold open: Error: connect ECONNREFUSED 172.20.0.2:5432
0:22 - Intro
0:29 - What Is Docker Compose?
0:46 - Anatomy of Compose File
1:24 - Top-Level Keys Reference
1:59 - Env Variables & Secrets
2:29 - .env vs environment Key
3:09 - Networking Basics
3:51 - Profiles & Overrides
4:28 - Volumes Persistence
5:02 - Custom Networks
5:38 - Healthchecks That Work
6:14 - Error: connect ECONNREFUSED 172.20.0.2:5432
6:37 - The Fix
6:52 - ⚠ Gotcha: Using depends_on without condition: service_healthy
7:07 - ⚠ Gotcha: Using localhost instead of service name
7:28 - ⚠ Gotcha: Hardcoding passwords in docker-compose.yml
7:42 - Wait-for-it Script for Readiness
7:59 - Compose V2 vs V1 Command Syntax
8:36 - Debugging Guide
8:58 - Interview Questions
9:21 - FAQ
9:45 - Key Takeaways
10:03 - Next up
10:15 - Wrap-up

👉 Full article + code: https://thecodeforge.io/devops/docker...
⏭ Next up: Docker Registry and Docker Hub

#docker #devops