When calling the spring boot plugin bootBuildImage task in gradle, a docker image is created using packeto. It starts the main class specified in the springBoot plugin. Below you can find an excerpt of the build.gradle file.
springBoot {
mainClass = 'MyMainApp'
}
bootBuildImage {
imageName = "$docker_repo/${project.name}"
}
When calling docker run
, docker will run a container starting MyMainApp
.
However, I want to run an alternative main class, using the same docker image. I tried the following:
- specifying
-Dloader.main=MyOtherApp
as the cmd indocker run
- specifying
-Dloader.main=MyOtherApp
in theJAVA_TOOL_OPTIONS
environment variable - specifying
LOADER_MAIN=MyOtherApp
as an environment variable
None of those options start MyOtherApp
.