Skip to content
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

Can this work with randomly chosen mapped port? #6

Open
SpyMachine opened this issue Dec 7, 2019 · 2 comments
Open

Can this work with randomly chosen mapped port? #6

SpyMachine opened this issue Dec 7, 2019 · 2 comments

Comments

@SpyMachine
Copy link

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.

@hey-johnnypark
Copy link
Owner

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?

@SpyMachine
Copy link
Author

SpyMachine commented Dec 11, 2019

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants