Adrian Krebs
Adrian Krebs

Reputation: 4387

How can I pass JAVA_OPTS to tomcat in a docker container?

I want to run my spring-boot application with a certain profile. Therefore, I need to pass the -Dspring.profiles.active=dev argument to the JVM.

My dockerfile looks like this:

FROM tomcat:9.0.10-jre8

EXPOSE 8080
ENV JAVA_OPTS="-Dspring.profiles.active=dev"
COPY myapp.war /usr/local/tomcat/webapps/myapp.war

The application starts but the JVM option with the profile name does not seem to be set. What am I missing?

Upvotes: 2

Views: 9684

Answers (1)

kakabali
kakabali

Reputation: 4033

Just simply add this in your Dockerfile :-

ENV spring.profiles.active=dev

and other option is below, by adding one ENTRYPOINT:-

ENTRYPOINT ["java","-Dspring.profiles.active=container","-jar","/app.jar"]

Upvotes: 5

Related Questions