Running and configuring postgres in docker

  • #db
  • #postgres
postgres reference

Description

Starting postgresql database quickly

Use those commands to quickly spin up postgres instance using docker. You can alter parameters using the form below to change the default configuration. It is useful for development environments or just testing.

Using psql to interact with postgres db

Using run psql command, you can start cli to interact with your postgres database. You can view and alter data using SQL, and use builtin commands such as:

  • \l list databases
  • \c <db-name> select database
  • \dt display tables

Accepted parameters


Available commands

run and destroy
Run just once and then destroy created containers
docker run --rm --name postgrestemp -p 5432:5432 -e POSTGRES_PASSWORD=mypassword -d postgres
create
docker run --name postgrestemp -p 5432:5432 -e POSTGRES_PASSWORD=mypassword -d postgres
start
docker start postgrestemp
stop
docker stop postgrestemp
remove
docker rm postgrestemp
run psql
Opens PostgreSQL interactive terminal
docker exec -it postgrestemp psql