DEV Community

Discussion on: Add a Postgres Database With Docker to Your Project

Collapse
 
zaffja profile image
Zafri Zulkipli

Nice article! For me, I try to assign a static IPV4 to the container, so each time I can connect using my DB GUI Dbeaver without changing the IP address each time I start the container

Collapse
 
sophiabrandt profile image
Sophia Brandt

That sounds like a good idea. But can't you connect to the database with localhost?

The alternative to hardcoding the values for Postgres would be to use environment variables, of course.

Collapse
 
zaffja profile image
Zafri Zulkipli

If inside the container, yes localhost is fine. But I don't know how else from host we can connect to container without using IP/port. And since docker will assign random IP address, my preference would always be to tell docker to assign specific IP.