# APM agent for Java docker application

**URL:** <https://discuss.elastic.co/t/apm-agent-for-java-docker-application/178035>\
**Category:** APM\
**Tags:** docker\
**Created:** [April 23, 2019, 12:03pm UTC](https://discuss.elastic.co/t/apm-agent-for-java-docker-application/178035 "2019-04-23T12:03:50Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![mugil1988](https://avatars.discourse-cdn.com/v4/letter/m/f14d63/32.png) [@mugil1988](https://discuss.elastic.co/u/mugil1988)\
**Post date:** [April 23, 2019, 12:03pm UTC](https://discuss.elastic.co/t/apm-agent-for-java-docker-application/178035/1 "2019-04-23T12:03:51Z")

</div>

Hi Team,

I am trying to configure Elastic APM for dockerized Java application..

Kindly let me know the steps to configure Java APM agent for docker Java apps..

Thanks,  
Mugil

---

<div class="post-metadata">

**Author:** ![Eyal\_Koren](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eyal_koren/32/36830_2.png) [@Eyal\_Koren](https://discuss.elastic.co/u/Eyal_Koren)\
**Post date:** [April 23, 2019, 12:32pm UTC](https://discuss.elastic.co/t/apm-agent-for-java-docker-application/178035/2 "2019-04-23T12:32:42Z")

</div>

Hi and welcome to the forum 🙂

You would have to copy the agent jar to the container's filesystem and then edit the command line that starts your Java app to contain the `-javaagent` flag with the proper jar location within the container.  
You can get general info about the Java agent setup options [in our documentation](https://www.elastic.co/guide/en/apm/agent/java/current/setup.html#setup). You can [configure the agent](https://www.elastic.co/guide/en/apm/agent/java/current/configuration.html#configuration) through system or environment properties, or through a configuration file (which you will have to make available in the container filesystem as well).

I hope this helps.  
Eyal.

---

<div class="post-metadata">

**Author:** ![felixbarny](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/felixbarny/32/27341_2.png) [@felixbarny](https://discuss.elastic.co/u/felixbarny)\
**Post date:** [April 23, 2019, 2:06pm UTC](https://discuss.elastic.co/t/apm-agent-for-java-docker-application/178035/3 "2019-04-23T14:06:59Z")

</div>

The [attach API](https://www.elastic.co/guide/en/apm/agent/java/current/setup-attach-api.html) is an alternative which does not require to copy the agent jar into the container. However, it is an additional dependency to your application.

---

<div class="post-metadata">

**Author:** ![mugil1988](https://avatars.discourse-cdn.com/v4/letter/m/f14d63/32.png) [@mugil1988](https://discuss.elastic.co/u/mugil1988)\
**Post date:** [April 23, 2019, 4:45pm UTC](https://discuss.elastic.co/t/apm-agent-for-java-docker-application/178035/4 "2019-04-23T16:45:25Z")

</div>

Hi Team,

My application is java based and deploying it as EAR file not JAR.

And there is no placeholder for Programmatic API setup.

I have added below lines in the Dockerfile and tried.

ADD elastic-apm-agent-1.6.0.jar $BWCE\_HOME

ENV JAVA\_OPTS=-javaagent:$BWCE\_HOME/elastic-apm-agent-1.6.0.jar -Delastic.apm.service\_name=hello -Delastic.apm.application\_packages=org.example -Delastic.apm.server\_url=http://192.168.43.87:8200

Still no luck.

Is there any other method?

Regards,  
Mugil

---

<div class="post-metadata">

**Author:** ![Eyal\_Koren](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eyal_koren/32/36830_2.png) [@Eyal\_Koren](https://discuss.elastic.co/u/Eyal_Koren)\
**Post date:** [April 24, 2019, 5:30am UTC](https://discuss.elastic.co/t/apm-agent-for-java-docker-application/178035/5 "2019-04-24T05:30:35Z")

</div>

Sorry, I don't know anything about working with BWCE.  
If the `JAVA_OPTS` variable contents are appended to the command line that runs the Java container that runs your EAR file, then this looks right (except from the `elastic.apm.application_packages`, which you should either omit or change to contain your application base java package). Otherwise, you would need to figure out what is the right way to configure the Java that runs this EAR.  
You should of course also make sure that the APM server URL you used is reachable from the container.  
Try looking in the application logs to get some feedback.  
Sorry I can't provide a lot of info, your knowledge in this env is surely much greater than mine.  
Eyal.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [May 15, 2019, 1:30am UTC](https://discuss.elastic.co/t/apm-agent-for-java-docker-application/178035/6 "2019-05-15T01:30:49Z")

</div>

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.
