-
Notifications
You must be signed in to change notification settings - Fork 137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
avoid port binding issues running create topic shell script within the container #11
Conversation
using KAFKA_JMX_PORT to prevent conflict precludes running scripts that call kafka-run-class.sh within the running container resulting in an exception (process spawned from kafka-start-server.sh already bound to the port defined) Error: Exception thrown by the agent : java.rmi.server.ExportException: Port already in use: 7203; nested exception is: java.net.BindException: Address already in use
default undefined variables to an empty string for expected beahvior when evaluating string length
Getting all the JMX settings is rather fiddly to get right. You're going to have to give an appropriately thorough description in your pull request about how this works, what problem this solves for you, etc. |
ches - I was looking for a working kafka container that could join an ensemble of zookeeper nodes and I didn't have any luck until trying yours. however attempting to verify beyond kafka registering with zk that it was indeed functional, I came up short attempting to create a topic when following the readme. I've corrected the issues encountered and tested them by creating an ensemble with 3 zk nodes and 3 kafka instances. following the quick start, single kafka container talking with a zookeeper ensemble - I receive an exception attempting to create a topic within the instance to the zk ensemble (those doing the quickstart with a single node to try it out will likely encounter this issue). Error: Exception thrown by the agent : java.rmi.server.ExportException: kafka-run-class.sh is aware of JMX_PORT the server script calls this script for which it then binds to 7203 as exported in the dockerfile to the environment. attempting to verify kafka is functional by running kafka-topics.sh to create a topic I receive the exception because this script calls kafka-run-class.sh which then attempts to spawn a process - instructed to bind to the same port declared by JMX_PORT and fails. Essentially, not exporting that variable solves the problem. My commits correct that problem as well as another. essentially, the KAFKA_JMX_OPTIONS don't get exported unless a value is passed during runtime given that it is being evaluated for length but isn't defined in this case. |
Thanks for the further explanation. I think I follow what you're getting at, but I'll need to make a few minutes to try to reproduce—can you give me an exact sequence of commands to reproduce your issue? I believe my fundamental question is, how are you running two processes in a container such that they conflict on binding the port? I assume that's the only way this would happen, and it's not really intended usage, but I'll try to see if there's a reasonable way to accommodate.
Can you elaborate on what you mean by "within the instance"? I assume this has to do with how you're ending up with two processes competing for the port.
I don't follow you. If the var is unset, then
|
He is executing a single process in the container (Kafka), but is attempting to execute I run into the same issue on my own containers. |
The changes outlined at the top of the post resolved the issue with the port binding. Further description of the build process follows: Containers were built using docker-compose, where container_name elements were added for both zookeeper and kafka. Also made the following (partial) change to expose ZOOKEEPER_IP for the start.sh script: kafka:
After docker-composer up -d and connecting the the kafka container using docker exec, the port binding problem occurred. Modifying the two files as indicated above allowed topics to be created, published and consumed from within the kafka container. |
Running into the same problem. Very annoying. As a workaround:
Is there still something blocking the merge of this? I'ld be happy to rebase the fix to master to make it mergeable again if you agree on the change @ches . |
kafka-topics.sh doesn't run out of the box.
The mentioned workaround
Shouldn't that be default? Or at least be mentioned in the docs? |
Ahhhhh so the problem here is
(Emphasis mine)—my README does not instruct people to use
Using This is a feature of last resort for unusual debugging situations. 95% of the time people are using I will not accept the changes proposed here because:
There is a simple solution: use If you really must By the way, you'll also likely encounter this problem if you run multiple container instances with |
Something I'll consider that would make this less likely to be encountered: giving Still though, break your |
No description provided.