-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Accessing Kafka container from another container #732
Comments
Hi @iNikem, Easy - just use re-mapped port 9093. See example here: |
Well, I can confirm it does work. But it's absolutely not obvious from public API. |
Essentially we have 2 addresses here. One is "external", for using from the tests, another one is "internal" for using from other containers on the same network. May be both should be exposed as public API? |
@iNikem well, ask Kafka guys why it is so 😄 Also, for your usecase, you don't really need KafkaContainer because the purpose of it is to simplify Kafka usage from the host because of NAT. In your case, simple |
Well, I want to communicate with Kafka from tests as well, so your proxy is still convenient. And I will make a PR to you, exposing |
@iNikem um... exposing 9093 doesn't make sense o_O What we could do, however, is to change the defaults and keep 9092 for the internal communication and some other port for the socat proxy |
@bsideup Why? By "exposing" I mean providing a nice method wrapping |
Like |
@iNikem ah, I see now. I'm afraid if we add such public method, users will try to use it instead of |
@bsideup I will try to come up with some scary name :) |
The method doesn't really makes any sense. What makes sense is to change the port back to 9092. I just submitted a PR for it: This way, you can use |
You still have to know that there are 2 different ways to communicate with Kafka: inside docker network and from your tests. |
Sounds like a good solution 👍 @iNikem You are right, but I'm afraid, this would also be the case if we add an additional public API method. |
@iNikem this applies to any container, actually. Either use exposed port on host or exposed inside the network |
Ok, thinking one more time about our requirements, the solution of #733 will satisfy us nicely :) Thanks! |
Released as 1.8.0 🎉 |
For my test I have to run 2 containers. One of them is
KafkaContainer
, another one is our application which uses that Kafka. Now, the problem is thatKafkaContainer
starts Kafka withADVERTISED_LISTENER
set to host ip of the Socat proxy container. Which is, obviously, not accessible from another container. #452 (comment) seems to be relevant here as well.So my question is: how can I run another testcontainer which needs to access
KafkaContainer
?The text was updated successfully, but these errors were encountered: