docker compose exec db psql -U app appdb -c 'SELECT 1'

Category: Web App Development

docker compose exec db psql -U app appdb -c 'SELECT 1'

Run psql inside the compose database service

Executes a query inside the running db service container without opening a shell first. The -c flag passes the SQL directly, and -U selects the app user against the appdb database. A 1 in the result confirms the database is healthy.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.