Java Docker Configuration
  • 1 Minute to read
  • Dark
    Light
  • PDF

Java Docker Configuration

  • Dark
    Light
  • PDF

Article summary

Follow the instructions here on how to add our profiler to your Dockerfile.

Environment Variables

Set the StackifyPrefix environment variable to 1 to set the profiler to Prefix mode.
This will put Prefix compatible traces in /usr/local/prefix/log (Unices) or %ALLUSERSPROFILE%\Stackify\Agent\log (Windows).

Binding the Host Trace directory to the Guest Trace directory

To get Prefix to read the traces from your app in docker, you need to use bind-mounts as mentioned in this article.

Example

If the host OS is Windows and you have a Linux OS in the container, you need to bind %ALLUSERSPROFILE%\Stackify\Agent\log to /usr/local/prefix/log for Prefix to see the logs.

Fixed Logging Directories for Java traces

Linux: /usr/local/prefix/log

Windows: %ALLUSERSPROFILE%\Stackify\Agent\log
%ALLUSERSPROFILE is an environment variable. This is usually located at C:\ProgramData but may be on another drive.
In Powershell, this would be $Env:ALLUSERSPROFILE.

This will work on Docker Desktop because it detects Windows style paths.

To bind these directories

We use the --mount argument for the docker run command as follows:
docker run -it --rm -p 8000:80 \ --mount type=bind,source="$Env:ALLUSERSPROFILE",target=/usr/local/prefix/log \ --name java_sample java-apm


Was this article helpful?

What's Next