Spring Boot Docker Deployment Steps
- Install Java.
sudo yum install java-1.8.0
sudo yum remove java-1.7.0-openjdk
- Install Maven
sdk install maven
Note: SDKMan can be used to install the maven.
Spring Boot Jar – Docker Deployment Steps:
Step 1: Create some folder in your linux machine.[create build folder inside /var]
Step 2: Docker deployment file creation
Create the below content as Dockerfile: [Filename: Dockerfile without any extension and must be available in “/var/build” path]
COPY yourjarname-1.0 yourjarname.jar
Here yourjarname-1.0 is assumed like the original file name which is created from spring boot and yourjarname.jar is the one you would like to rename it.
Step 3: Put the above created docker file and your spring boot jar in same folder. [/var/build]
Now Dockerfile and yourjarname.jar file available in /var/build path.
Step 4: Remove the existing container if any
Not needed if you are doing first time, needed if you want to deploy from second time.
sudo docker rm -f yourdockercontainername || true
Step 5: Docker build command
sudo docker build -t yourjarname /var/build/
Step 6: Running Docker Container of Your Jar
#define your port below
sudo docker run -d –name yourjardockercontainername -p 8443:8443 -t yourjarname
Here yourjardockercontainername can be used to see the logs of your spring boot jar file.
docker logs yourjardockercontainername.
Docker useful commands for Beginners:
930 total views, 4 views today