I'm trying to get JMX to work with spotify/kafka
Docker image.
I have a docker-compose.yml
with:
version: '2'
services:
my-kafka:
image: spotify/kafka # Using this instead of wurstmeister's because it didn't work with /var/run/docker.sock on Windows while this one has integrated ZK and works
hostname: my-kafka
restart: unless-stopped
ports:
- "9092:9092" # Kafka
- "2181:2181" # Zookeeper
- "7203:7203" # JMX
environment:
KAFKA_ADVERTISED_HOST_NAME: my-kafka
KAFKA_ADVERTISED_PORT: 9092
KAFKA_OPTS: "-Dcom.sun.management.jmxremote=true -Dcom.sun.management.jmxremote.rmi.port=7203 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=my-kafka"
I then try to test it using jconsole my-kafka:7203
and getting a 'Connection failed: error during JRMP connection establishment; nested exception is: java.io.EOFException.' immediately. By contrast, using a non-existent host leads to "Unknown host" and a different port to "Connection refused".
docker ps
shows:
692eb6659aba spotify/kafka "supervisord -n" 10 minutes ago Up 10 minutes 0.0.0.0:2181->2181/tcp, 0.0.0.0:7203->7203/tcp, 0.0.0.0:9092->9092/tcp docker_my-kafka_1
ps aux
within the container shows:
root 11 1.8 3.3 5718844 274608 ? Sl 06:16 0:12 /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java -Xmx1G -Xms1G -server -XX:+UseG1GC -XX:MaxGCPauseMillis=20 -XX:InitiatingHeapOccupancyPercent=35 -XX:+DisableExplicitGC -Djava.awt.headless=true -Xloggc:/opt/kafka_2.11-0.10.1.0/bin/../logs/kafkaServer-gc.log -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false ...offtopic skipped... -Dcom.sun.management.jmxremote=true -Dcom.sun.management.jmxremote.rmi.port=7203 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=my-kafka kafka.Kafka /opt/kafka_2.11-0.10.1.0/config/server.properties
The container log is boring without JMX being even mentioned, ends with "kafka entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)".
There is a related question kafka monitoring using JMX when running kafka in docker in boot2docker but I'd prefer to stick to spotify/kafka
so that ZK & Kafka live in the same container.