Connect To Postgres database running on a Docker container using psql

ankitbrijwasi

ankit-brijwasi

Posted on October 16, 2021

Connect To Postgres database running on a Docker container using psql

Recently while working, I was required to connect to a database that was running on a docker container using psql.

If you are also dealing with something like this, then, follow along

1. Start the docker container

$ docker run -d container_name
Enter fullscreen mode Exit fullscreen mode

2. Now run the following command

$ psql -h localhost -p 5432 -U username -d database_name
Password for user username:

psql (12.8 (Ubuntu 12.8-0ubuntu0.20.04.1))
Type "help" for help.
database_name=> 
Enter fullscreen mode Exit fullscreen mode

And that's it
Thank you for reading!
Have a nice day!πŸ˜‡

πŸ’– πŸ’ͺ πŸ™… 🚩
ankitbrijwasi
ankit-brijwasi

Posted on October 16, 2021

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related