- This application we are going to containerize.
- Project zip file will be downloaded. Extract the zip and import to VS Code.
- Add an index.html to the main/resources/static folder.
- Run the application.
- Verify the application is running or not.
- if the application works fine in the localhost next we are going to containerize the application.
- In VS Code run as maven build.
- It will create a jar file, which is used for the deployment of an application.
FROM openjdk:17
WORKDIR /app
COPY demo_DockerProject-0.0.1-SNAPSHOT.jar /app/spring-boot-app.jar
EXPOSE 8080
CMD ["java", "-jar", "spring-boot-app.jar"]
Run the build command to create a docker image from the docker file sudo docker build -t spring-boot-app . Check the image is created or not sudo docker images
-
First tag the image with username of the github account docker tag spring-boot-app-image github(username)/spring-boot-app
-
docker login (give the username and password for docker hub)
-
docker push (pushing image to dockerhub) docker push github(username)/spring-boot-app
- Run the application as container in detached mode and on system port 8090. docker run -d -p 8090:8080 spring-boot-app-image
- Then check if the container is created or not. docker ps (command will give you the created container id)
- http://publicip:8090 Application successfully deployed