docker-kafka-zookeeper
docker-kafka-zookeeper copied to clipboard
Can this work with randomly chosen mapped port?
Hi, I really want to be able to use this docker image with https://github.com/testcontainers/testcontainers-rs but the problem is the ports will be randomly mapped for me and it seems like that breaks some things internally. Is it possible to use this container with randomly chosen mapped ports? I can run some exec commands after the fact if that's the only way.
Hi @SpyMachine , just to understand your idea. You want to be able to set the container internal ports for zookeeper and kafka at runtime. For example being able to change the Kafka port from 9092 to a different port?
Hmm, well so I want to be able to use this as a container when the internal port will be randomly mapped to a host port using the "-P" option for docker run
.
I'm not really too sure on the specifics on how one would make that happen.
For example I tried running docker run -p 2182:2181 -p 9093:9092 -e ADVERTISED_HOST=localhost johnnypark/kafka-zookeeper:latest
but when I setup a producer and consumer against 9093, I get:
[2019-12-11 07:51:06,228] WARN [Producer clientId=console-producer] Connection to node 0 (localhost/127.0.0.1:9092) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient)
I'd also need the Zookeeper port to be random as well.
Make sense?