Definitive Notes on Docker and Postgres

Every once in a while I have to spin up a postgres dockerize instance to play around, and since 2017 it’s been a pain having to go through the docs just to get things working.
So now this is where I’m going to come back whenever I need to do that.

Creating the Container

Docs doesn’t mention the port, but here we use -p to bind it.

Connecting via psql

and then

Notice that we have to explicitly pass the localhost host, because by default Postgresql connects to a unix domain socket (I’m wondering what’s this)

Bonus: connecting from inside the container itself

Jack Of All Trades