1

I am trying to create my own Spring Boot application with a POSTGRESQL database. I have started using docker to mount the database, with a docker-compose whose values ​​are as follows:

version: "3"
services:
    products-postgresql:
      image: postgres:9.6
      restart: always
      ports:
        - 5450:5432
      environment:
        POSTGRES_USER: postgres
        POSTGRES_PASSWORD: superadmin
        POSTGRES_DB: products
      volumes:
        - D:\microservicios\workspace\SpringSecurity\volumes:/var/lib/postgresql/data:rw

With the docker-compose up -d command, I managed to get it up easily, enter image description here enter image description here

The problem occurs to me when trying to connect with DBeaver to the database. I have configured it as a new POSTGRESQL connection, passing the connection data similar to those of docker-compose, (database = products, host = localhost, user = postgres, password = superadmin....) but it returns FATAL error: database "products" does not exist.

Imagen de conexion con DBeaver

I've seen similar posts, like this psql: FATAL: database "" does not exist , but they don't work for me. I have verified that I don't have any other application using the same port.

Could you tell me what I may be doing wrong, or what I have left to configure? Thanks

UPDATE: Image showing that the container lifts my database

From Docker

Talenel
  • 422
  • 2
  • 6
  • 25

1 Answers1

0

Although I still don't understand why, I had to change the port of my container to 5432 (the one used by POSTGRESQL), and it finally worked for me.

version: "3"
services:
    products-postgresql:
      image: postgres:9.6
      restart: always
      ports:
        - 5432:5432
      environment:
        POSTGRES_USER: postgres
        POSTGRES_PASSWORD: superadmin
        POSTGRES_DB: products
      volumes:
        - D:\microservicios\workspace\SpringSecurity\volumes:/var/lib/postgresql/data:rw
Talenel
  • 422
  • 2
  • 6
  • 25
  • That means you had another (vestigial) instance of PostgreSQL running on port 5450, which was overcasting the one you intended. And hence, by changing the port number, it worked for you as you were able to connect to the intended instance. – Amith Kumar Jul 05 '23 at 17:40