DEV Community

kumar ankit
kumar ankit

Posted on

How to create a docker image for any Java project

So you have finally decided to move to micro-services architecture or may be you have just decided that you want to run your application to run in a Kubernetes cluster. May be your requirement is to use cloud services like AWS, GCP, AZURE, etc … to scale immediately as per demand. Or may be … just may be you are here to learn how to convert your existing java application into a docker image so that it can be containerized by whoever wants it.
Whatever may your requirement there is no denying that tech world is moving toward cloud and containerizing your application is one of the easiest and most efficient way to start your journey towards cloud infrastructure.

What is Docker ?
Docker is a tool designed to make it easier to create, deploy, and run applications by using containers. Containers allow a developer to package up an application with all of the parts it needs, such as libraries and other dependencies, and deploy it as one package.
In a way, Docker is a bit like a virtual machine. But unlike a virtual machine, rather than creating a whole virtual operating system, Docker allows applications to use the same Linux kernel as the system that they're running on and only requires applications be shipped with things not already running on the host computer. This gives a significant performance boost and reduces the size of the application. [1]
In this Article i will show how you can configure a java application with maven to generate a docker image that contains all the dependencies and configurations. I will be using a very simple spring application written in Java 8 for demonstration. I will also be using fabic8 maven-docker-plugin to automate the image generation process.

For detailed steps follow the article here:

how to create a docker image for any java project

Please feel free to share your thoughts and idea on the article. Also it will be great help if you have some feedback so i can improve the article further.

Feel free to fork me on Github.

Article repository:

Top comments (0)