Install APM Insight Java Agent in Docker


Follow the steps below to install the APM Insight Java agent in a Docker container:

Step 1. Download and extract the agent

Download the latest APM Insight Java agent (apminsight-javaagent.zip) and extract it to a local folder.

Ensure that the apminsight-javaagent.jar, apminsight-javaagent-api.jar, and the configuration files (like apminsight.conf) are present in the extracted agent directory.

Step 2. Configure the agent

Edit the apminsight.conf file to include your license key, APM server URL, and application name:

license.key=[LICENSE_KEY]
apm.host=http://[HOST]:[PORT]
application.name=[APP_NAME]

Replace the following placeholders with the actual values:

  • [LICENSE_KEY] – License key from Applications Manager APM Insight tab
  • [HOST]/[PORT] – APM Manager host and port
  • [APP_NAME] – The application’s name
Example:
license.key=APMI_74447444b...
apm.host=http://apm-prod-server:9090
application.name=Docker_Server

Note: For alternate configuration using Java System Properties, refer to our guide.

Step 3. Modify your Dockerfile

Copy the agent and configure the startup options:

# Create agent folder
RUN mkdir -p <APP_DIR>/apminsight
# Add agent files
ADD <LOCAL_AGENT_DIR>/ <APP_DIR>/apminsight/
# Activate agent on startup
ENV JAVA_OPTS="$JAVA_OPTS -javaagent:<APP_DIR>/apminsight/apminsight-javaagent.jar"

Replace the following placeholders with the actual values:

  • <APP_DIR> – Your application folder in the container
  • <LOCAL_AGENT_DIR> – Local folder with extracted agent files

Step 4. Build and run

Save the Dockerfile, rebuild your Docker image, and start the container. Once the container is running and your application is accessed, data will begin appearing under the APM Insight → Applications section in the Applications Manager web console.

Note:
  • For secure connections, use an HTTPS APM URL (ensure certificates are valid): https://apm-prod-server:8443.
  • To support APM Manager failover (for Java Agent v6.8 and above), specify multiple hosts: apm.host=http://apm-A:9090,http://apm-B:9090

Example (Tomcat)

Here’s a sample Dockerfile incorporating the Java agent:

FROM tomcat
COPY sample.war /usr/local/tomcat/webapps/
# Add the APM Insight agent
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: The -javaagent parameter is required for the agent to load. This method should work across application servers, but may need tweaks depending on your environment.

Thank you for your feedback!

Was this content helpful?

We are sorry. Help us improve this page.

How can we improve this page?
Do you need assistance with this topic?
By clicking "Submit", you agree to processing of personal data according to the Privacy Policy.