Search code examples
spring-bootdockerh2

Spring Boot 3 doesn't run in Docker


I have a Spring Boot 3 project with a H2 database that I want to run in a Docker container, but it doesn't run.

I'm using those commands:

docker build -t spring-hope .
docker run -p 8080:8080 spring-hope

This is the configuration:

application.yml:

spring:
  application:
    name: hope
  datasource:
    driver-class-name: org.h2.Driver
    username: sa
    password:
  jpa:
    database-platform: org.hibernate.dialect.H2Dialect
    hibernate:
      ddl-auto: update
  properties:
    jakarta.persistence.jdbc.url: jdbc:h2:mem:testdb
    hibernate.dialect: org.hibernate.dialect.H2Dialect
  h2:
    console:
      enabled: true
      path: /h2-console
server:
  error:
    include-message: always
    include-binding-errors: always

And it throws this exception: https://github.com/ocardenasmartinez1984/hope/blob/main/error.txt

This is the repository: https://github.com/ocardenasmartinez1984/hope

What is going on guys?


Solution

  • I cloned your GitHub-repository and changed your application.yml to a minimum, and app starts without errors. Built with ./gradlew clean bootJar, then ran the Docker-commands.

    spring:
      application:
        name: hope
    
      jpa:
        open-in-view: false
        hibernate:
          ddl-auto: update
    
      h2:
        console:
          enabled: true