I want to build new Spring Boot backend and run it with docker (Dockfile and docker-compose.yml) including a volume-mapping to be able to code live.
Here’s my Dockerfile (in the project directory)
FROM jelastic/maven:3.9.5-openjdk-21 AS build
WORKDIR /app
COPY .mvn/ .mvn
COPY mvnw pom.xml ./
RUN ./mvnw dependency:go-offline
COPY src ./src
FROM openjdk:21 AS runner
WORKDIR /app
ENV SPRING_DEVTOOLS_OPTIONS="restart=on-failure"
COPY --from=build /app/ .
EXPOSE 8081
CMD ["./mvnw", "spring-boot:run"]
and my docker-compose.yml (in the same directory)
services:
backend:
build:
context: .
dockerfile: Dockerfile
ports:
- "8081:8081"
volumes:
- ./:/app
environment:
- SPRING_DEVTOOLS_OPTIONS=restart=on-failure
I’m starting it simply via docker-compose up
I already tried to deinstall docker desktop, restart the pc and install again but that didn’t work (got it from another thread).
I want to develope locally live so I don’t have to rebuild the whole thing when I make changes in the code.
The container was built but just after the boot of Spring Boot it says:
Using Docker Compose file ‘/app/docker-compose.yml’
Application run failed
Unable to start docker process. Is docker correctly installed?