Docker Spring Boot
April 24, 2020
I wanted to create a docker container of a spring boot application running on Java 11, and to then run that up inside docker.
That can be done with the following Dockerfile
# Build FROM maven:3.6.0-jdk-11-slim AS build COPY src /home/app/src COPY pom.xml /home/app RUN mvn -f /home/app/pom.xml clean package # Package FROM openjdk:11 COPY --from=build /home/app/target/todo-0.0.1-SNAPSHOT.jar /usr/local/lib/todo-0.0.1-SNAPSHOT.jar EXPOSE 8080 ENTRYPOINT ["java","-jar","/usr/local/lib/todo-0.0.1-SNAPSHOT.jar"]
This can be built into a docker container using:
$ docker build -t drumcoder/todo-backend .