Follow the steps given below to install Java agent in Docker:
license.key=[LICENSE KEY]
apm.host=http://[HOST]:[PORT]
application.name=[APPLICATION NAME]
Example:
license.key=APMI_74447444b666d7ab5174cc3021a9b68dd4b3364d50f99c2969360810313e8fac
apm.host=http://apm-prod-server:9090
application.name=Docker_Server
To learn more about the configurations, visit our Configuration Guide page.
Note: Alternatively, the APM Insight application configuration parameters can also be configured as Java System Properties instead of modifying the apminsight.conf file. Learn more
#Creating a new directory 'apminsight' under the specified app directory location
RUN mkdir -p <APP_DIRECTORY_PATH>/apminsight
#Adding the agent directory files into the specified app directory path under 'apminsight'
ADD <Agent_directory_path>/ <APP_DIRECTORY_PATH>/apminsight/
#Configuring Java agent into the application
ENV JAVA_OPTS="$JAVA_OPTS -javaagent:<APP_DIRECTORY_PATH>/apminsight/apminsight-javaagent.jar"
Following is an example of the commands used for configuring the agent into the image file Dockerfile for Tomcat servers:
FROM tomcat
COPY sample.war /usr/local/tomcat/webapps/
#Add the apminsight and -javaagent parameters
RUN mkdir -p /usr/local/tomcat/apminsight
ADD ./apminsight/ /usr/local/tomcat/apminsight/
ENV JAVA_OPTS="$JAVA_OPTS -javaagent:/usr/local/tomcat/apminsight/apminsight-javaagent.jar"
EXPOSE 8080
CMD ["catalina.sh","run"]
Note: To add the agent to server, the -javaagent argument needs to provided. However, this method is a generic solution and may require some modifications depending on your app server/user environment.