Java APM with Docker
  • 1 Minute to read
  • Dark
    Light
  • PDF

Java APM with Docker

  • Dark
    Light
  • PDF

Article summary

This document details how to install the Java APM Profiler in your Java application running on Docker or Docker Swarm.

Prerequisite

Follow the Retrace Docker Install Guide.

Java Docker Setup

Dockerfile Configuration

Adjust your Dockerfile to include the Java Profiler:

RUN mkdir -p /stackify-java-apm && \
    cd /stackify-java-apm && \
    wget https://download.stackify.com/stackify-java-apm/stackify-java-apm-latest.tar.gz; tar -zxvf  stackify-java-apm-latest.tar.gz; rm stackify-java-apm-latest.tar.gz && \
    ./install.sh

Enabling the Java Agent

Follow Enable the Stackify Java Profiler instructions based on the application server being used.

Note: Adjust the Java Profiler path to: /stackify-java-apm/stackify-java-apm.jar.

Running your Application

Start your application with the stackify shared volume. Customize the STACKIFY_APPLICATION_NAME and STACKIFY_ENVIRONMENT_NAME values.

docker run -v stackify:/usr/local/stackify \
--env STACKIFY_APPLICATION_NAME="My Java Application" \
--env STACKIFY_ENVIRONMENT_NAME="Production" \
[your-application-image] 

Verify

Make application requests, you can then verify results in the Retrace dashboard.

Troubeshooting

  • Running in Docker Swarm requires that STACKIFY_DOCKER_ENABLED be set when running your application. This can be done using -DSTACKIFY_DOCKER_ENABLED=true.

Was this article helpful?