Dockerizing a Spring Boot Application or Push Image on Docker hub Account

Опубликовано: 23 Декабрь 2020
на канале: The Muzaffar Method: Ops Unlocked
504
13

We will cover the two most commonly used approaches:

Dockerfile: specifying a file that contains native Docker commands to build the image

Maven: Using a Maven plugin to build the image

Dockerizing using Dockerfile:

FROM openjdk:8-jdk-alpine
ARG JAR_FILE=target/spring-boot-web.jar
WORKDIR /opt/app
COPY ${JAR_FILE} app.jar
ENTRYPOINT ["java","-jar","app.jar"]

Let's build the image using this Dockerfile:

$ docker build -t spring-boot:1.0 .
$ docker images
$ docker run -d -p 8080:8080 -t spring-boot:1.0
$ docker ps