0

I am trying to pass JAVA_OPTS to my entrypoint but all syntax that I have tried isn't working. Here is my code:

ENTRYPOINT ["java", $JAVA_OPTS, "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:8008", "-cp","app:app/lib/*","gov.aus.mkt.data.MktApp", "--spring.redis.host=redis"]

Is there any way to pass $JAVA_OPTS from environment variable defined on docker-compose?

While I was searching on internet, I also find some posts about being a bad practice use entrypoint as I am doing. What is the "right" way and why?

edit:

Solved it using explicit exec:

ENTRYPOINT exec java $JAVA_OPTS -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:8008 -cp app:app/lib/* gov.aus.mkt.data.MktApp --spring.redis.host=redis

Is it a good practice? Why?

placplacboom
  • 614
  • 8
  • 16
  • This seems like basically the same question as [Use environment variables in CMD](https://stackoverflow.com/questions/23071214/use-environment-variables-in-cmd); do the answers there help you? – David Maze Jan 30 '23 at 23:38
  • I tend to prefer `CMD` over `ENTRYPOINT` for being a little easier to override and for fitting nicely into the entrypoint-wrapper pattern. A shell-form (bare string) `ENTRYPOINT` can be problematic for completely ignoring the command part (or any arguments passed after the `docker run image-name`). But that's mostly my opinion, and I've seen commentary preferring `ENTRYPOINT` as well. – David Maze Jan 30 '23 at 23:40

0 Answers0