ENTRYPOINT defines what Docker runs when a container starts from an image. Use it to make the image launch a specific application, such as a Java program packaged in a JAR. section 4.2
Listing 4.2 Dockerfile for building a Java app with Maven
FROM diamol/maven:2e AS builder WORKDIR /usr/src/iotd COPY pom.xml . RUN mvn -B dependency:go-offline COPY . . RUN mvn package # app FROM diamol/openjdk:2e WORKDIR /app COPY --from=builder /usr/src/iotd/target/iotd-service-0.1.0.jar . EXPOSE 80 ENTRYPOINT ["java", "-jar", "/app/iotd-service-0.1.0.jar"]
See a complete Dockerfile that copies a compiled JAR into a runtime image and starts it with ENTRYPOINT. section 4.2
Start a Java application
ENTRYPOINT ["java", "-jar", "/app/iotd-service-0.1.0.jar"] After building the image, run it with `docker container run --name iotd -d -p 800:80 --network nat image-of-the-day`. Docker starts Java with the application JAR, while the image exposes port 80. section 4.2


