docker run -d --name dev-postgres -e POSTGRES_PASSWORD=dev -p 5432:5432 postgres:16

Category: Web App Development

docker run -d --name dev-postgres -e POSTGRES_PASSWORD=dev -p 5432:5432 postgres:16

Run a throwaway Postgres 16 container for dev

Starts Postgres 16 in a detached container named dev-postgres, with the password env var set and port 5432 published. The -d flag daemonizes it and -p maps the port. Connect with psql -h localhost -U postgres, and remove the container with docker rm -f dev-postgres when done.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.