Murat
Murat

Reputation: 23

How can I connect to a PostgreSQL server running inside a Docker container on a GCP virtual machine?

I have pgAdmin4 and PostgreSQL running inside Docker containers on a GCP virtual machine. I have already ingested data into PostgreSQL and I can access the tables and databases using pgcli. However, I am unable to connect to pgAdmin4. How can I connect to the pgAdmin4?

Upvotes: 1

Views: 88

Answers (1)

Valerie Parham-Thompson
Valerie Parham-Thompson

Reputation: 1566

You will access pgadmin with your browser.

When you start up the pgadmin container, you should have configured a port mapping. Add a firewall rule to your VM's network configuration for this mapped port (for example, I've configured an ingress firewall rule for 15432 because I mapped 15432 to 80 in my docker config).

Example snippet from docker-compose:

ports:
      - 15432:80

Assuming you have configured an external IP address, use the external IP address and the port number in your browser to access pgadmin. Like this, where XX.XX.XX.XXX is your external IP and 15432 was mapped to port 80:

http://XX.XX.XX.XXX:15432/login

Upvotes: 1

Related Questions