docker-compose depends on 数据库

version: "3.3"
services:
web:
build: .
ports:
- "4242:4242"
environment:
DATABASE_URL: postgres://postgres:unleash@db/postgres
depends_on:
- db
command: >
sh -c "
while ! nc -z db 5432; do
echo 'Postgres is unavailable.'
sleep 1
done
npm run start"
db:
expose:
- "5432"
image: postgres:10-alpine

推荐阅读更多精彩内容