---
title: Docker Container JVM Monitoring - JMX Monitoring Agent Guide
description: Monitor JVM applications running in Docker containers and Kubernetes pods using the Nodinite JMX Monitoring Agent. Configure JMX remote ports for containerized Java workloads.
---

# <i class="fab fa-docker" aria-hidden="true"></i> Docker Container JVM Monitoring

This troubleshooting guide explains **container monitoring** for a **container JVM** so you can configure **JMX remote** access, **container port** mapping, and **Docker network** connectivity for the <span class="nodinite-product-name" title="The node that unites different systems. Or as we call it Nodinite">Nodinite</span> [JMX Monitoring Agent][JMXAgent].

## How JMX Monitoring Works with Docker

When a JVM runs inside a Docker container, the JMX port is bound inside the container and must be exposed to the host network using Docker port mapping. The Spring Boot Gateway then connects through the Docker network to the host IP on the mapped port.

<div class="mermaid">
graph LR
  subgraph "Docker Host"
    subgraph "Container: boomi-atom"
      JVM["fab:fa-java Boomi Atom JVM<br/>port 5002 (internal)"]
    end
    subgraph "Host Network"
      PORT["Host port 5002"]
    end
    GW["fa<i class="fal fa-server" aria-hidden="true"></i> Spring Boot Gateway"]
  end
  subgraph "Agent Host"
    AGENT["fa<i class="fal fa-monitor-waveform" aria-hidden="true"></i> JMX Monitoring Agent (IIS)"]
  end
  JVM -->|JMX| PORT
  GW -->|5002| PORT
  AGENT -->|8080| GW
  style JVM fill:#2678BD
  style PORT fill:#FFD525
</div>

*Diagram: JMX monitoring for a JVM in a Docker container, where the JMX port is mapped from the container to the host network for Spring Boot Gateway access.*

## Configuring JMX Remote for Docker Containers

### Step 1: Expose the JMX Port in Docker

Add JMX remote flags to the JVM startup command and expose the port in the Docker configuration:

```bash
java \
  -Dcom.sun.management.jmxremote=true \
  -Dcom.sun.management.jmxremote.port=5002 \
  -Dcom.sun.management.jmxremote.rmi.port=5002 \
  -Dcom.sun.management.jmxremote.authenticate=false \
  -Dcom.sun.management.jmxremote.ssl=false \
  -Djava.rmi.server.hostname=<DOCKER_HOST_IP> \
  -jar myapp.jar
```

<aside aria-label="Important" class="nodinite-note nodinite-note--important">
<p class="nodinite-note__label" aria-hidden="true"><i class="far fa-fw fa-message-exclamation"></i> Important</p>
<div class="nodinite-note__content"><p>The <code>-Djava.rmi.server.hostname</code> parameter must be set to the <strong>Docker host IP address</strong>, not <code>localhost</code> or the container IP. This is the IP that the Spring Boot Gateway uses to connect back to the JVM. Without this setting, JMX connections from outside the container will fail.</p></div>
</aside>

### Step 2: Map the Port in Docker Run or Compose

**Docker Run:**

```bash
docker run -p 5002:5002 my-java-app
```

**Docker Compose:**

```yaml
services:
  boomi-atom:
    image: boomi/atom:latest
    ports:
      - "5002:5002"
    environment:
      - JAVA_OPTS=-Dcom.sun.management.jmxremote.port=5002 ...
```

### Step 3: Configure in Nodinite JMX Agent

In the [JMX Monitoring Agent Configuration][Configuration]:

* <i class="fal fa-server" aria-hidden="true"></i> **Address** - The Docker host IP address, not the container IP
* <i class="fal fa-network-wired" aria-hidden="true"></i> **Port** - The mapped host port, 5002 in the example above
* <i class="fal fa-memory" aria-hidden="true"></i> **Heap monitoring** - Enable Heap Size thresholds for the target container JVM
* <i class="fal fa-microchip" aria-hidden="true"></i> **CPU monitoring** - Enable CPU thresholds for the target container JVM

## Kubernetes Considerations

For JVMs running in Kubernetes pods, JMX monitoring requires either:

* Exposing the JMX port via a Kubernetes `NodePort` or `LoadBalancer` service
* Running the Spring Boot Gateway as a sidecar container in the same pod

<aside aria-label="Note" class="nodinite-note nodinite-note--note">
<p class="nodinite-note__label" aria-hidden="true"><i class="far fa-fw fa-note"></i> Note</p>
<div class="nodinite-note__content"><p>In Kubernetes environments, pod IP addresses change on pod restarts. Use a Kubernetes Service with a stable DNS name or static NodePort to provide a consistent JMX endpoint for the <span class="nodinite-product-name" title="The node that unites different systems. Or as we call it Nodinite">Nodinite</span> monitoring agent.</p></div>
</aside>

## Common Docker JMX Issues

### Spring Boot Gateway cannot connect to a containerized JVM

**Cause:** The `-Djava.rmi.server.hostname` value is not set or is set to `localhost` or the container IP.

**Resolution:** Set `-Djava.rmi.server.hostname=<DOCKER_HOST_IP>` where `<DOCKER_HOST_IP>` is the IP address reachable by the Spring Boot Gateway.

### JMX connects successfully but heap metrics show zero

**Cause:** The JVM inside the container reports zero heap if the container has memory limits but the JVM is not configured to respect them.

**Resolution:** Add `-XX:+UseContainerSupport` in JDK 8u191+ and JDK 10+ to enable JVM container awareness. This allows the JVM to detect Docker memory limits and set heap accordingly.

### JMX expose settings are correct but metrics still fail

**Cause:** The published port is not reachable from the Docker host or another Docker network segment.

**Resolution:** Verify the container port mapping, host firewall rules, and Docker network routing between the Spring Boot Gateway and the target container.

## <i class="fal fa-hand-point-right" aria-hidden="true"></i> Next Steps

<i class="fal fa-unlock" aria-hidden="true"></i> [Enable JMX Remote Monitoring][]  
<i class="fal fa-file-invoice-dollar" aria-hidden="true"></i> [Costs and Licensing][]  

## <i class="fal fa-link-horizontal" aria-hidden="true"></i> Related Topics

<i class="fal fa-server" aria-hidden="true"></i> [Multi-JVM Monitoring][]  
<i class="fal fa-display" aria-hidden="true"></i> [OS vs JVM Monitoring][]  
<i class="fal fa-circle-question" aria-hidden="true"></i> [JMX Troubleshooting Overview][Troubleshooting]  

[Configuration]:https://docs.nodinite.com/logging-and-monitoring/jmx/getting-started/configuration/
[Costs and Licensing]:https://docs.nodinite.com/logging-and-monitoring/jmx/troubleshooting/costs-and-licensing/
[Enable JMX Remote Monitoring]:https://docs.nodinite.com/logging-and-monitoring/jmx/troubleshooting/enable-jmx-remote-monitoring/
[JMXAgent]:https://docs.nodinite.com/logging-and-monitoring/jmx/overview/
[Multi-JVM Monitoring]:https://docs.nodinite.com/logging-and-monitoring/jmx/troubleshooting/multi-jvm-monitoring/
[OS vs JVM Monitoring]:https://docs.nodinite.com/logging-and-monitoring/jmx/troubleshooting/os-vs-jvm-monitoring/
[Troubleshooting]:https://docs.nodinite.com/logging-and-monitoring/jmx/troubleshooting/overview/