This content originally appeared on DEV Community and was authored by ankit-brijwasi
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
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=>
And that's it
Thank you for reading!
Have a nice day!😇
This content originally appeared on DEV Community and was authored by ankit-brijwasi

ankit-brijwasi | Sciencx (2021-10-16T05:54:44+00:00) Connect To Postgres database running on a Docker container using psql. Retrieved from https://www.scien.cx/2021/10/16/connect-to-postgres-database-running-on-a-docker-container-using-psql/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.