Tooling · Postgres
Local Postgres in one command
Every new project needs a database, and installing Postgres by hand on each machine gets old fast. PgQuick is a small Docker Compose setup that gives you PostgreSQL plus pgAdmin, wired together, with one command.
github.com/waux-team/PgQuickWhy bother
A native Postgres install works until it doesn't: two projects want different major versions, a brew upgrade breaks the data directory, or a teammate's setup drifts from yours. Running the database in a container fixes all three. The version is pinned in a file, the data lives in a named volume, and everyone on the team starts from the same config.
PgQuick is that config, and nothing else. The whole repo is four files:
docker-compose.yaml— the Postgres and pgAdmin services.env.example— credentials and the database name.gitignore— keeps your real.envout of gitREADME.md— the two ways to start it
What you get
| Service | Image | Reach it at |
|---|---|---|
| Postgres | postgres:15-alpine | localhost:5432 |
| pgAdmin | dpage/pgadmin4:8 | http://localhost:8080 |
Both ports are bound to 127.0.0.1, so the database is reachable from your machine only, not from anyone else on the same Wi-Fi.
Quick start
You need Docker with the Compose plugin (Docker Desktop, OrbStack or Colima all work).
1. Clone the repo
git clone https://github.com/waux-team/PgQuick.git
cd PgQuick2. Create your .env
cp .env.example .envThen open .env and change the passwords and the database name:
DATABASE_URL="postgres://admin:strong_password_here@localhost:5432/project_db_name?schema=public"
POSTGRES_USER=admin
POSTGRES_PASSWORD=strong_password_here
POSTGRES_DB=project_db_name
PGADMIN_EMAIL=admin@admin.com
PGADMIN_PASSWORD=strong_password_hereKeep DATABASE_URL in step with the three POSTGRES_* values. It isn't used by Compose; it's there so you can paste it straight into your app's own .env. The ?schema=public suffix is the form Prisma expects.
3. Start it
docker compose up -d4. Check it's healthy
docker compose pspostgres_db should show healthy. pgAdmin waits for that before it starts, so give it a few seconds on the first run.
Inside the compose file
The file is short, but a few lines are doing more than they look.
A real health check
healthcheck:
test: ["CMD-SHELL", "pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}"]
interval: 10s
timeout: 5s
retries: 5
start_period: 10spg_isready asks Postgres whether it is accepting connections. The doubled $$ stops Compose from substituting the variable itself, so the shell inside the container expands it instead. pgAdmin then uses that result:
depends_on:
db:
condition: service_healthyWithout the condition, Compose would only wait for the container to start, not for the database to be ready.
Guard rails
deploy:
resources:
limits:
memory: 1G
logging:
driver: json-file
options:
max-size: "10m"
max-file: "3"The memory cap keeps a runaway query from eating your laptop. The log rotation keeps Docker's logs at 30 MB per service at most, instead of growing until the disk fills up.
Data that survives restarts
volumes:
postgres_data:
pgadmin_data:Named volumes outlive the containers. docker compose down and up again, and your tables and saved pgAdmin servers are still there.
Connecting
From pgAdmin
Open http://localhost:8080 and sign in with PGADMIN_EMAIL and PGADMIN_PASSWORD. Then register a server:
- Host:
db - Port:
5432 - Username / password: your
POSTGRES_USERandPOSTGRES_PASSWORD
Use
db, notlocalhost. pgAdmin runs in its own container, wherelocalhostmeans pgAdmin itself. Both services share thepg-networkbridge, so the service namedb(or the container namepostgres_db) resolves to the database.
From your app
Your app runs on the host, so it uses localhost. Copy DATABASE_URL into the app's .env:
DATABASE_URL="postgres://admin:strong_password_here@localhost:5432/project_db_name?schema=public"From a terminal
No local psql needed. Use the one inside the container:
docker exec -it postgres_db psql -U admin -d project_db_nameThe manual way
If you only want the database and no pgAdmin, a single docker run does it:
docker run -d \
--name my-postgres \
-e POSTGRES_USER=admin \
-e POSTGRES_PASSWORD=secret \
-e POSTGRES_DB=mydb \
-p 5432:5432 \
-v pgdata:/var/lib/postgresql/data \
postgres:16Two differences from the Compose setup: this one runs Postgres 16 rather than 15, and -p 5432:5432 publishes the port on every network interface, not only on 127.0.0.1. Use -p 127.0.0.1:5432:5432 if you want the same local-only behaviour.
Stopping and resetting
docker compose stop # pause, keep everything
docker compose down # remove containers, keep data
docker compose down -v # remove containers AND wipe all data
down -vdeletes both named volumes. Every table and every saved pgAdmin server is gone, with no undo. Dump anything you need first withpg_dump.
Common snags
- Port 5432 is already in use. Another Postgres is running on the host. Stop it, or change the left side of the mapping to
"127.0.0.1:5433:5432"and use port5433inDATABASE_URL. - Changed the password in
.envbut login still fails. Postgres only readsPOSTGRES_PASSWORDthe first time it creates the data directory. Change it withALTER USERinpsql, or reset withdown -v. - pgAdmin keeps restarting.
PGADMIN_EMAILmust be a valid email address; pgAdmin refuses to start with anything else.
That's the whole setup: clone, copy the env file, docker compose up -d. One database per project, the same version for everyone, and nothing installed on the host besides Docker.