How to run Spring Boot application in Docker | Spring Boot Docker| ​⁠@javacodeex

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello everyone welcome to my channel in this video we'll explore how to dockage spring boot application so we'll create one simple spring boot application first and we'll see how to create the docker file for that and we'll dockerize this spring boot application we'll see this process in step by step let's get started so first we'll create simple springbot application from start. spring. iio so here my springbot version 3.3 and here I'm creating group ID a tech and artifact ID spring docker and we'll add dependencies so here we are creating simple application so I'm added web and one more I will add lambach we'll go with simple application and our goal is to doize our spring boot applications okay now we can generate this project so project is generated now we import this project into intellig ID yeah I have imported project into D ID if you see the bomb. XML file I have only now and L also there now we'll create Docker file for this so before creating the doer file first we'll create One controller and that controller we add one Endo to test our application so first we can create controller package and inside the controller we'll create One controller class we'll create like hello controller so this is the controller class annotation just controller and annotation request mapping now we'll add one get API inser this class public stream get message so it will return welcome to Spring boot Docker okay so this is normal G you can use annotation get mapping so this is the controller I created only one Point that's is/ API and it will return welcome to Spring boot container so here I'm not creating any service any repositories just we can try with one simple flow with this you'll get to know how this Docker flow will work and how to dockerize our springboard application okay so now we need to create our Docker file in the class path so can right click new can click the file now you can give Docker file for this phone don't specify any extension just you can click Dark Earth file only okay so it should be out of it should be a Class part so see now it is class bar this is our do so what are the steps here following the docker file First Step you need to pull the jdk and after that we need to point to the working directory then you can move to the jar file to the working directory then you can expose to the port number then you can run this jar file using Java jar those are the steps we need to follow inside the daer file you see this is jdk 17 and after that this is working directory then I'm copying this J to this target to this and I'm exposing H already I'm using Serv so Java I jar app. jar okay so here so what is this our application name we need to give so in if you go with the p. XML file it is outside the plugins we need to use the find name so it will generate jar with this name here bu is Success now we need to go to the docker file part then we'll run this Docker file so our Docker file is there W springboard 3 and spring Docker so we need to go to this so here if you see this is my Docker file now you need to run Docker build doer build iph T image name we need to give spring iph Docker this is there in this current directory okay so now it is starting building Docker so there is issue Do jar Do jar it should be single Do jar can correct this one and again we'll rebuild this once build is done again we need to do the darker build yeah this build is Success now we'll do it from this command promp using Docker build ion T spring iphon Docker so first it will pull the image like jdk 17 dependency after that it will copy the jar then it will expose the port number 9898 after that it should run the jar file so First Once build is done we'll do it Docker run command still it is downloading it will take two to 3 minutes based on the internet connectivity okay now it is done now you can run this Docker command Docker run I the command we need to use Docker P 9898 spring I docker why I'm not giving 880 because 880 is already running other services in my system so I'm using 989 you can use 80 8 Z also so once it is started now we can see the docker desktop so here is our new do container 9898 this is a port number so there is one container if you come to the image also spring iPhone do in use Okay so are able to see this containers in the doer desktop just quickly check is this yeah now it is see so if you see 9898 why it is not coming if you see this logs this stom server is showing 8080 so we are missed to specify 9898 server. port number in the springboard application come to that application properties here you can mention okay we'll rebuild this one one more time because we did some changes in the application properties we'll try to rebuild this after that we'll build from the docker and we'll again rerun from the docker because this changes is not reflect here it is showing still 80 80 only you can stop this it stopped now build success now yes we can do the docker build once Docker build is done now it will won't take that much time because already that Tucker container is there right it is download again so Docker build I spring iPhone Docker image Docker build already done we need to use Docker run so if you perform this Docker run and will observe this port number see now it is showing 98 98 so just you need to remember while giving the port number so whatever the port number you giving from this D file this port number you need to link with this application. port number okay so then only it will show here 98 98 now right so now you can test this application so Local Host 98 98 SL AP see now we are getting the response from our spring boot application now our spring boot application is dockerized okay so like this you canly spin board into darker container I hope this video is helpful for you please like share and subscribe my channel
Info
Channel: Java Codeex
Views: 609
Rating: undefined out of 5
Keywords: dockerize spring boot application, spring boot, spring boot docker, dockerize spring boot, dockerize spring boot app, how to dockerize a spring boot application, how to dockerize spring boot application with mysql, spring boot docker tutorial, dockerize java application, deploy spring boot application to docker, dockerize spring boot angular8 application, dockerize spring boot application with mysql, spring, spring boot tutorial, spring boot quick start guide
Id: oDDBtp70pWU
Channel Id: undefined
Length: 10min 24sec (624 seconds)
Published: Mon Jun 17 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.