This page describes how to use a Docker file to copy the App Server Agent files to the Docker image.

When the Cluster Agent is installed in a cluster, AppDynamics recommends Cluster Agent auto-instrumentation. See Auto-Instrument Applications with the Cluster Agent.

A common method to instrument a containerized application is to include the AppDynamics App Server Agent when building the application image. You add a COPY command to the Dockerfile to copy the agent files to the image. The COPY command copies the application binary to the Docker container image. If an App Server Agent upgrade is required, you must rebuild the image with the new agent files.

See the language-specific container installation page for instructions on how to use a Dockerfile:

Dockerfile Example

In this example for a Java application, the Java Agent files in the AppServerAgent folder are copied to the application image and the application JAR file. The agent environment variables are set before the start script runs.

FROM openjdk:8-jre-slim

COPY myapp.jar /app
COPY AppServerAgent/ /opt/appdynamics

ENV APPDYNAMICS_AGENT_APPLICATION_NAME=<value>
ENV APPDYNAMICS_AGENT_TIER_NAME=<value>
ENV APPDYNAMICS_AGENT_ACCOUNT_NAME=<value>
ENV APPDYNAMICS_AGENT_ACCOUNT_ACCESS_KEY=<value>
ENV APPDYNAMICS_CONTROLLER_HOST_NAME=<value>
ENV APPDYNAMICS_CONTROLLER_PORT=<value>
ENV APPDYNAMICS_CONTROLLER_SSL_ENABLED=<value>
ENV APPDYNAMICS_JAVA_AGENT_REUSE_NODE_NAME=true
ENV APPDYNAMICS_JAVA_AGENT_REUSE_NODE_NAME_PREFIX=<value>

COPY ./startup.sh /startup.sh
RUN chmod +x /startup.sh
ENTRYPOINT ["/bin/bash", "/startup.sh"]
CODE