Your data. Anywhere you go.

New Relic for iOS or Android


Download on the App Store    Android App on Google play


New Relic Insights App for iOS


Download on the App Store


Learn more

Close icon

Setting newrelic environment in distroless docker container

environment

#1

We previously used -Dnewrelic.environment=${profile} in our docker files to select the desired newrelic config based on what environment variable docker sets at startup. recently we switched to a distroless java container (gcr.io/distroless/java:8) with no variable substitution. we tried setting an environment variable with no luck: NEW_RELIC_ENVIRONMENT=DEV, NEW_RELIC_CONFIG_ENVIRONMENT=DEV had no effect (but, e.g. NEW_RELIC_AGENT_ENABLED=false works).
what is a sensible way to work around this without including a shell into our container?

EDIT: to clarify: the distroless image uses exec form of ENTRYPOINT, and there’s no shell by default to get variable substitution. using JAVA_TOOL_OPTIONS might be an option but none of the minor variations of “JAVA_TOOL_OPTIONS=-Dnewrelic.environment=DEVELOPMENT” worked for us.


#2

Huh. Not sure what we did wrong before, but JAVA_TOOL_OPTIONS does in fact work, so I guess this can be ignored.


#3

Hello @vilius.vaivada, that’s cool. Thanks for letting us know that worked for you! :slight_smile: