Tutorial - build docker image with java maven build

we want to build up an docker enviroment with our microservices. Registry and first stuff is everything running. But for the next steps I already know some stuff but the complete picture is hard to get.

What do i want to do.

I have a Java maven projects. Some with a database and some not. (normal stuff)

Now I want to build the project and put in into a docker image which i than can tag and push into our repository.

I don’t want to build a jar/war in one step and than start a docker file which copies this file into a tomcat. I would like to have the possibility to use one command which creates an docker image. perfect would be if I could use maven profiles for different environments and stuff.

Since this is not very complex stuff, I think their must be some tutorials which describe how to do this.

I know that their are some projects which say, they make it easier but you can also do it with standard docker software, which I would like to use.

Until now I couldn’t find any good tutorial for maven docker integration. Does anybody knows one?

You need to use maven plugin for docker.
Here is a nice tutorial (java) how to set your pom.xm for docker.

I recommend you to use the pom.xml which is available here:

remember that you need to set some variables such as your project mainClass

and also archetype according to your project…

after you set this just run : mvn clean package docker:build
and it will compile your project and build a docker image.

Then, you need to run your image : docker run -d yourimagename .

Good luck!