Multi-container development with Docker Compose
Running a web app, a DB, and a cache each with docker run means memorizing long commands per container and wiring up networks by hand. The more common problem is that the app comes up before the DB is ready and dies on a connection error. Docker Compose declares the whole stack in one YAML file and brings it up with a single command. The thing that actually trips you up with multiple containers is service startup order. The stack below starts the app only after the DB is ready. Running docker compose up confirms the order holds in the log. The output comes from a run on Docker Compose v5.1.1. ...