Skip to content

Instantly share code, notes, and snippets.

@vallamost
Last active April 4, 2025 17:19
Show Gist options
  • Save vallamost/d353f7c52a6bb32f64fa50c868aa768a to your computer and use it in GitHub Desktop.
Save vallamost/d353f7c52a6bb32f64fa50c868aa768a to your computer and use it in GitHub Desktop.
Live Notes - Postgres

Monitoring

Good postgres monitoring tool:

sudo apt install pg_activity

Usage: pg_activity -U testuser -h localhost -d testdb

Postgres Container Creation

Start a postgres container with a persistent volume, use for development.

docker run -d --name postgres_betterauth_dev -p 5432:5432 -e POSTGRES_USER=auth_service_user -e POSTGRES_PASSWORD=develop -e POSTGRES_DB=auth_db_dev_proxy1 -v auth_db_postgres_vol:/var/lib/postgresql/data postgres
# Command to forcibly stop and delete the container and volume when you're done.
# Requires Powershell 7+ on Windows.
docker rm -f postgres_betterauth_dev && docker volume rm auth_db_postgres_vol

Start a small container of postgres on Windows using the host networking mode

docker run -d `
   --name my_postgres `
   --network host `
   -e POSTGRES_USER=testuser `
   -e POSTGRES_PASSWORD=qwerty `
   -e POSTGRES_DB=testdb `
   postgres

Start a small container of postgres on Windows exposing the port without host networking

docker run -d `
   --name my_postgres `
   -p 5432:5432 `
   -e POSTGRES_USER=testuser `
   -e POSTGRES_PASSWORD=qwerty `
   -e POSTGRES_DB=testdb `
   postgres
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment