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

Bonus: connecting from inside the container itself

docker exec -it strapi-postgres bash # opens shell in container
psql -U mycustomuser # won't even ask for password.




Jack Of All Trades

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Applications of python

data science and data visualization

2021 IaC Forecast: 5 Predictions for the Upcoming Year

Introducing the New GraphAcademy

Running goloop 0.9.5+JavaEE natively (without Docker) ☕

Begin Your Career in JAVA (Part-1)

Nokia G11

Real-Time Analytics: COVID-19 Weekly Roundup May 12th, 2021

How to Build Basic Chatbot Without Coding

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
Alex Alonso

Alex Alonso

Jack Of All Trades

More from Medium

Deploy to Kubernetes in 5 minutes with Docker Compose and Okteto Cloud

Migrate Keycloak H2 database to Postgres on Kubernetes

Build and monitor your FastAPI microservice with Docker, Prometheus and Grafana. [Part-1]

How to deploy micro-services on kbernetes, hands on tutorial !