Using Postgres inside docker container

These are my personal notes. Am running postgres docker image on a local linux box.

If port 5432 is already in use, run this to see what process is using it:

the above command will also display the pid using which you can kill the process. For example, if the pid is 1667, kill it by sudo kill 1667

Now sudo launch the shell script that runs the docker image.

Connecting to the postgres database within the container

First get the pid of the docker process: sudo docker ps

Now login to the root of the docker instance: sudo docker exec -it bdd95244ce47 bash
(Here bdd95244ce47 was the pid of the docker process from prev step, change it to whatever the pid is)

Then login to postgres root like so; psql -U postgres

then you can list databases like so: \l

connect to database: \c whatever_db_name

display all tables within connected database: \dt




No Comments


You can leave the first : )



Leave a Reply

Your email address will not be published. Required fields are marked *