Definitive Notes on Docker and Postgres

Creating the Container

docker run \
--name strapi-postgres \
-p 5432:5432 \
-e POSTGRES_PASSWORD=mycustompassword \
-e POSTGRES_USER=mycustomuser -d postgres
-e POSTGRES_DB=mycustomdatabase

Connecting via psql

sudo apt install postgresql # for ubuntu/debian based
psql -h localhost -p 5432 -U mycustomuser
docker exec -it strapi-postgres bash # opens shell in container
psql -U mycustomuser # won't even ask for password.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store