I'm trying to run tomcat in a container and want to pass DB_HOST
as a environment variable.
I tried starting the container as docker run -e DB_HOST='dbhost001' -p 8080:8080 image_id
. But that doesn't seem to work
Data.properties:
db.machine=${DB_HOST}
db.dbname=users
db.username=test
db.password=test
Figured it out.
Add
propertyConfigure
forservlet xml file
like below:Modify db.properties file like below:
Pass the variable to tomcat as
CATALINA_OPTS="-Dkey=value"
when starting tomcat.In my case it was docker container. So starting it as following worked.