Introduction to Python Programming Language

Python is developed by Guido van Rossum. Guido van Rossum started implementing Python in 1989. Python is a very simple programming language so even if you are new to programming, you can learn python…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Dockerize A Spring Boot Application

Containers are standard units of software that package up code and all its dependencies so that the application runs quickly and reliably from one computing environment to another.

Docker File, Docker Image and Docker Containers are three important components of a dockerised project.

Docker File: A Docker File is text document which contains the instructions required by docker to build a Docker Image.

Docker Image: A docker image can be considered to be a template which is used to create Docker Containers. These images are read-only templates and form the building blocks of a Docker Container.

Docker Container: A Docker Container is a running instance of a Docker Image as they hold the entire package needed to run the application.

For Maven- You just have to run the below command and there is no need to modify your pom.xml to include the Jib dependency.

For Gradle- You need to add the Jib plugin in your build.gradle file as-

Or in the older style as-

Once you have added the plugin, refresh your Gradle dependencies by-

Or by clicking the reimport button in your respective IDE.

Then, run the following command-

The above command builds and pushes a container image for your application to a container registry.

The Docker File looks like-

2. Next, run the below command to generate the jar file of your application.

For Maven-

For Gradle-

3. Now create the docker image by executing the below command.

For Maven-

For Gradle-

To wrap up the above steps, the build will create a spring user and a spring group to run the application. It will later COPY the project JAR file into the container as "app.jar" that will be executed in the ENTRYPOINT.

To list the docker images use-

And to run the docker image use-

I hope you have understood how to containerise a Spring Boot application using Docker. Thank you for reading 😊.

Add a comment

Related posts:

VANDALISED PERIYAR STATUE CREATES A CONTROVERSY

The unknown faces tarnishing the Dravidar Kazhagam’s founder, Periyar Statue in the Kaliyapettai, near Uthiramer in Kancheepuram has created a controversy. The undisclosed miscreants had already…

Becoming a best learner

Life is not a bed of roses, it’s full of thorns. For competing the world and market, we have to learn new things, develop new skills. But the thing is that learning is not easy. To listen to…

Technology Is Driving Commercial Real Estate Trends

Marc Lair is president and CEO of The Equitable Group, Inc., in San Diego, California. In this capacity, Marc Lair guides all of the firm’s investment activities in the commercial real estate sector…