Skip to main content

Command Palette

Search for a command to run...

How to access postgresql DB running inside a docker via terminal

Updated
1 min read
How to access postgresql DB running inside a docker via terminal

First make sure you have postgresql-client installed:

sudo apt-get install postgresql-client

Next, you need to find the IP address of the Docker container running PostgreSQL. You can do this by running the following command:

docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' <container_name>

Once you have the IP address, you can connect to the PostgreSQL instance using the psql command. Run the following command in your terminal:

psql -h <ip_address> -U <username> -d <database_name>

More from this blog

B

bmax

25 posts