So I have this Java Springboot MySql web project that works perfectly when run locally. I am trying to dockerize it creating a Springboot image of it, then use docker-compose to run it with another mysql image.
As Spring says, I used this command to generate the image:
mvnw spring-boot:build-image
It got built perfectly, but when I try to run a container with it, I get communication error with the database.
I'm guessing I'm not writting the database info correctly in my .properties file, but I've been trying different configs and nothing changes... this is what I got in my local project:
# ---
spring.jpa.hibernate.ddl-auto=update
spring.jpa.properties.hibernate.globally_quoted_identifiers=true
# ---
server.port=8081
## MySQL
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL8Dialect
spring.datasource.url=jdbc:mysql://localhost:3306/bookshelter
spring.datasource.username=user
spring.datasource.password=1234
Am I forced to use a MySql Docker container when running a Docker Spring project? Can't I use my local database with a Dockerized project? What should I change in my .properties?