Skip to main content

Connecting the PostgreSQL container with a DB management tool

  • Download pgAdmin4 v8

  • Make sure that the Rancher Desktop is on and the container created for the pulled Postgres image has been Started in the Containers tab.

  • Open the pgAdmin and navigate to Dashboard → Add New Server

  • Move over to the connections tab and enter the credentials.

  • Enter localhost in the hostname tab

  • If the port has been changed, then enter the updated port number. Default Postgres is set to 5432

  • Enter the username and password that were used when you run the Postgres container

  • If unable to find the containers, start the postgres container from the rancher desktop. Then open cmd

  • type docker ps to check the status of the containers.

  • Copy the container ID or the name (here “some-postgres”)

  • type docker inspect “your containerID”

  • After this scroll and look for your credentials

  • Appropriately enter your credentials in pgAdmin and click on save establish a connection between the pgAdmin and your Postgres docker container.

  • Make sure that the Rancher Desktop is on and the container created for the pulled Postgres image has been Started in the Containers tab.

Now, Connect the postGres (container) setup to your SpringBoot application via application properties

spring.application.name=demo server.port=8081 spring.datasource.url=jdbc:postgresql://localhost:5432/postgres spring.datasource.username=postgres spring.datasource.password=mysecretpassword spring.jpa.hibernate.ddl-auto=update

Sample Application.properties configuration

Was this page helpful?