-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
How to configure docker-compose.yml for Kafka local development? #385
Comments
Does the wiki not address your question? https://github.com/wurstmeister/kafka-docker/wiki/Connectivity And duplicate #352 |
@Cricket007 Thanks, it worked. But now I can't produce from inside a Consumer. Simply a Consumer can't produce and call another consumer. Any idea why? |
I'm not sure I understand. Are you trying to use Kafka Streams and sending one topic to another? |
Not streams. Let's say I have topic A... In its consumer, when the work is complete, it will produce to topic B... For example, topic A gets a file from a remote server, topic B, uploads the file to a different storage server. |
I see no reason why that wouldn't work if you are able to individually produce and consume. I would suggest using Streams API, though, instead if the intention is sending data between topics. For example, consume topic "filenames", |
Solved. Not an issue with docker 😄 Some code refining I did while working on this issue. But here's how I solved the connectivity issue: https://stackoverflow.com/questions/51919584/how-to-configure-docker-compose-yml-for-kafka-local-development I exposed the kafka port to the local machine:
|
Glad to hear! As mentioned in the comments, there on your post, though, I linked to "recommended" way, using the listener mapping |
@Cricket007 Great thanks! I'll have a look at that now. |
For some reason, it does not work for me. I have tried putting
My app has a producer but it can't recognize the Kafka broker on localhost. |
Because that's the only address you have advertised... What's the problem? |
So, when I change my
to
along with changing the Producer config like this: It does not work for me. I am doing this in Java. My app container throws an error saying that the broker might be disconnected. |
|
Also, Have you read the Docker networking documentation?
|
Thanks for the help. I have been going through several stack overflow questions ranging back 4 years so that's why deprecated features are there. Let me look at it and implement. For the broker, I am going to try and put a internal IP address and see if it works after that. |
You should never use IPs in Docker networks. Always service names (aka DNS) |
I have been doing that and it works great. The requirement from the team came was to either use localhost or internal IP address but based on our discussion and your awesome feedback, I can go back to team and say this is not the best practice. I am still new to docker so went with the team's requirement. Again, thanks for all your help, I really appreciate it. |
In order to use localhost, your Java app needs to run outside of any container, as I refer to in my Stackoverflow answer there, but this also means you would be running code on a physical broker server, which should never happen in production, anyway |
Hi, I'm trying to setup Kafka in a docker container for local development. My docker-compose.yml looks as follows:
Unfortunately my node app running on my localhost (not in docker) cannot connect to it. I used the url 'kafka:9092' and even 'localhost:9092'. Nothing works. Any idea what's happening?
The text was updated successfully, but these errors were encountered: