Docker Entrypoint does not consider mainClass option (and resulted script name)
See original GitHub issueExpected behaviour
I have a project with multiple main classes and as state here: https://www.scala-sbt.org/sbt-native-packager/archetypes/java_app/index.html#usage I use
mainClass in(Compile, run) := Option("com.<redacted>.Boot")
The scripts in bin result with boot
name which I think is to be expected.
Building the docker image for the project I expect the image to start properly.
Actual behaviour
The Entrypoint in the image is wrong, using project name and not considering the given mainClass
option.
From docker inspect
ENTRYPOINT [\"/opt/microservice/bin/<project-name>\"]
Information
Plugin version: 1.7.0 SBT: 1.3.10 Built on Linux
Related options:
val dockerSettings = Seq(
defaultLinuxInstallLocation in Docker := "/opt/microservice",
dockerRepository in Docker := Some("<docker-registry>"),
dockerExposedPorts in Docker := Seq(8080),
// Ignore this, we need to run as root for now
daemonUser in Docker := "root",
daemonUserUid in Docker := None,
version in Docker := version.value
)
Issue Analytics
- State:
- Created 3 years ago
- Comments:12 (6 by maintainers)
Top Results From Across the Web
Cannot run script.sh with ENTRYPOINT Docker - Stack Overflow
When I run the container as mentioned above, I get the following error: : not foundta/script.sh: 2: /usr/src/data/script.sh: 's ...
Read more >A Start to Finish Guide to Docker with Java - Stackify
Read an extensive, start to finish guide to building, managing and running a containerized Java Spring Boot application.
Read more >Topical Guide | Spring Boot Docker
This is a guide for developers of Spring Boot applications, and containers are not always a good abstraction for developers. They force you...
Read more >Run a Java application in a Docker container | IntelliJ IDEA ...
In the New Project dialog, select New Project and name the project DockerHelloJava . New Java project. Create the main Java class file...
Read more >Demystifying ENTRYPOINT and CMD in Docker - Amazon AWS
Specifying CMD in a Dockerfile merely creates a default value: if we pass non-option arguments to docker run , they will override the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks for your help!
Thanks for your patience @MihaiAnei 😅 Of course that’s the issue 🤦
I found the root cause. It’s, as quite a few times, a scoping issue. So the fix ist
the
mainClass in (Compile,run)
(I used the new syntax in the example above) isn’t used for setting theexecutableScriptName
. So it falls back to the default behaviour.The default behaviour, generating a script per class, doesn’t work very well with the docker plugin. However I’m fine with that as a docker image ideally as one entry point. IMHO that’s the point of having containers 😜 If you have multiple main classes, then setting the “default” one should be fine.
Thanks again for your help 😗