docker run --name postgresDb -e POSTGRES_PASSWORD=sweabhishek -d -p 5432:5432 postgres
postgresql://postgres:mysecretpassword@localhost:5432/postgres?sslmode=disable
-name postgresDb β Container name = postgresDbe POSTGRES_PASSWORD=sweabhishek β Sets the password for the default postgres userp 5432:5432 β Maps port 5432 on your local machine to port 5432 inside the containerpostgres β Uses the official PostgreSQL imageBy default, this container creates:
postgressweabhishekpostgres5432localhostpsql -h localhost -p 5432 -U postgres -d postgres
Then itβll ask for your password (sweabhishek).
If you want to pass the password inline (for automation/testing):