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!π
Top comments (0)