How to connect to containerized database with its IP?


Newbie docker user here.
I successfully created a Postgres container my-database and am able to access it from SQLTools on my local machine with server address localhost and the port.

I got the containerized database’s IP address from the following command:

docker container inspect my-database

But when I go back to SQLTools or the PHP web application(not containerized) and try to connect to my-database with the IP address I got above, it couldn’t connect successfully.

What am I missing here?

FYI, I also created another container and was able to connect to my-database with the following way: Use the same network for both my-database and the second container.

Source: Docker Questions

Categorised as database, docker, host, localhost, postgresql Tagged , , , ,


Leave a Reply

Still Have Questions?

Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us