12. Docker – Implementation => Project one
Docker – Implementation
=> Project one
This project can be download from this
github URL.
This is very basic spring boot project
to test docker containerization.
Open Spring tool suit.
Create new Spring boot Proj name docker-springBoot-one
Create a controller class under src directory.
Go to pom.xml and give a custom name to
the jar file which will be generated (docker_SB_1).
..
Go to application properties file.and
give a server port.
server.port=8081
Create Docker file name Dockerfile and
add below configuration.
FROM openjdk:11
ARG JAR_FILE=target/docker_SB_1.jar
COPY ${JAR_FILE} app.jar
EXPOSE 9091
ENTRYPOINT ["java","-jar","/app.jar"]
Right click on the project => run as
=> maven install.
Then jar file is generated in the
target folder with named docker_SB_1.
Then run the project and see the
output.
Then go to the project folder. Inside docker-springBoot-one
you can see Dockerfile also. Right click in the docker-springBoot-one folder
and open in terminal.
docker build -f Dockerfile -t sb_prj_one_img .
docker images
docker run -p 8081:8081 --name sb_prj_one_cont -d
sb_prj_one_img
OR
docker run -p 7081:8081 --name sb_prj_one_cont -d
sb_prj_one_img
docker container ls
Comments
Post a Comment