Kafka access inside and outside docker
up vote
2
down vote
favorite
I'm trying to start a kafka service using docker-compose, and it should be able to be accessed inside and outside docker. So, it should be matter of setting the right advertisers inside and outside:
version: '3'
services:
zookeeper:
image: wurstmeister/zookeeper
ports:
- "2181:2181"
kafka:
image: wurstmeister/kafka
ports:
- "9094:9092"
environment:
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: INSIDE:PLAINTEXT,OUTSIDE:PLAINTEXT
KAFKA_LISTENERS: INSIDE://:9092,OUTSIDE://127.0.0.1:9094
KAFKA_ADVERTISED_LISTENERS: INSIDE://:9092,OUTSIDE://127.0.0.1:9094
KAFKA_INTER_BROKER_LISTENER_NAME: INSIDE
The problem is that when I try to connect from outside the cluster, I don't get 127.0.0.1 as the name of the node, but the internal hostname:
$ kafkacat -L -b 127.0.0.1:9094
Metadata for all topics (from broker -1: 127.0.0.1:9092/bootstrap):
1 brokers:
broker 1001 at 91588ea968d4:9092
28 topics:
...
Isn't the purpose of KAFKA_ADVERTISED_LISTENERS and KAFKA_LISTENERS to handle that situation? I tried setting KAFKA_ADVERTISED_HOST_NAME but it's ignored (one piece of documentation says it's deprecated, other one says that it's still active), but nevertheless that doesn't seem to be the answer, since I want two different advertised hostnames for two different networks.
I guess the old question remains: how to make kafka work inside and outside docker-compose?
docker apache-kafka docker-compose
add a comment |
up vote
2
down vote
favorite
I'm trying to start a kafka service using docker-compose, and it should be able to be accessed inside and outside docker. So, it should be matter of setting the right advertisers inside and outside:
version: '3'
services:
zookeeper:
image: wurstmeister/zookeeper
ports:
- "2181:2181"
kafka:
image: wurstmeister/kafka
ports:
- "9094:9092"
environment:
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: INSIDE:PLAINTEXT,OUTSIDE:PLAINTEXT
KAFKA_LISTENERS: INSIDE://:9092,OUTSIDE://127.0.0.1:9094
KAFKA_ADVERTISED_LISTENERS: INSIDE://:9092,OUTSIDE://127.0.0.1:9094
KAFKA_INTER_BROKER_LISTENER_NAME: INSIDE
The problem is that when I try to connect from outside the cluster, I don't get 127.0.0.1 as the name of the node, but the internal hostname:
$ kafkacat -L -b 127.0.0.1:9094
Metadata for all topics (from broker -1: 127.0.0.1:9092/bootstrap):
1 brokers:
broker 1001 at 91588ea968d4:9092
28 topics:
...
Isn't the purpose of KAFKA_ADVERTISED_LISTENERS and KAFKA_LISTENERS to handle that situation? I tried setting KAFKA_ADVERTISED_HOST_NAME but it's ignored (one piece of documentation says it's deprecated, other one says that it's still active), but nevertheless that doesn't seem to be the answer, since I want two different advertised hostnames for two different networks.
I guess the old question remains: how to make kafka work inside and outside docker-compose?
docker apache-kafka docker-compose
Can you link to the two docs you mention that are inconsistent? It would be good to fix them if there is an ambiguity.
– Robin Moffatt
Nov 11 at 11:47
It's in hub.docker.com/r/wurstmeister/kafka section "listener configuration". It's not kafka documentation, but wurstmeister docker image: " Later versions of Kafka have deprecated advertised.host.name and advertised.port. NOTE: advertised.host.name and advertised.port still work as expected, but should not be used if configuring the listeners."
– jdinunzio
Nov 11 at 12:37
Ah right. FWIW Confluent have a full set of Kafka images here: hub.docker.com/u/confluentinc
– Robin Moffatt
Nov 11 at 12:51
add a comment |
up vote
2
down vote
favorite
up vote
2
down vote
favorite
I'm trying to start a kafka service using docker-compose, and it should be able to be accessed inside and outside docker. So, it should be matter of setting the right advertisers inside and outside:
version: '3'
services:
zookeeper:
image: wurstmeister/zookeeper
ports:
- "2181:2181"
kafka:
image: wurstmeister/kafka
ports:
- "9094:9092"
environment:
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: INSIDE:PLAINTEXT,OUTSIDE:PLAINTEXT
KAFKA_LISTENERS: INSIDE://:9092,OUTSIDE://127.0.0.1:9094
KAFKA_ADVERTISED_LISTENERS: INSIDE://:9092,OUTSIDE://127.0.0.1:9094
KAFKA_INTER_BROKER_LISTENER_NAME: INSIDE
The problem is that when I try to connect from outside the cluster, I don't get 127.0.0.1 as the name of the node, but the internal hostname:
$ kafkacat -L -b 127.0.0.1:9094
Metadata for all topics (from broker -1: 127.0.0.1:9092/bootstrap):
1 brokers:
broker 1001 at 91588ea968d4:9092
28 topics:
...
Isn't the purpose of KAFKA_ADVERTISED_LISTENERS and KAFKA_LISTENERS to handle that situation? I tried setting KAFKA_ADVERTISED_HOST_NAME but it's ignored (one piece of documentation says it's deprecated, other one says that it's still active), but nevertheless that doesn't seem to be the answer, since I want two different advertised hostnames for two different networks.
I guess the old question remains: how to make kafka work inside and outside docker-compose?
docker apache-kafka docker-compose
I'm trying to start a kafka service using docker-compose, and it should be able to be accessed inside and outside docker. So, it should be matter of setting the right advertisers inside and outside:
version: '3'
services:
zookeeper:
image: wurstmeister/zookeeper
ports:
- "2181:2181"
kafka:
image: wurstmeister/kafka
ports:
- "9094:9092"
environment:
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: INSIDE:PLAINTEXT,OUTSIDE:PLAINTEXT
KAFKA_LISTENERS: INSIDE://:9092,OUTSIDE://127.0.0.1:9094
KAFKA_ADVERTISED_LISTENERS: INSIDE://:9092,OUTSIDE://127.0.0.1:9094
KAFKA_INTER_BROKER_LISTENER_NAME: INSIDE
The problem is that when I try to connect from outside the cluster, I don't get 127.0.0.1 as the name of the node, but the internal hostname:
$ kafkacat -L -b 127.0.0.1:9094
Metadata for all topics (from broker -1: 127.0.0.1:9092/bootstrap):
1 brokers:
broker 1001 at 91588ea968d4:9092
28 topics:
...
Isn't the purpose of KAFKA_ADVERTISED_LISTENERS and KAFKA_LISTENERS to handle that situation? I tried setting KAFKA_ADVERTISED_HOST_NAME but it's ignored (one piece of documentation says it's deprecated, other one says that it's still active), but nevertheless that doesn't seem to be the answer, since I want two different advertised hostnames for two different networks.
I guess the old question remains: how to make kafka work inside and outside docker-compose?
docker apache-kafka docker-compose
docker apache-kafka docker-compose
edited Nov 11 at 12:00
David Maze
8,5182821
8,5182821
asked Nov 11 at 9:53
jdinunzio
551217
551217
Can you link to the two docs you mention that are inconsistent? It would be good to fix them if there is an ambiguity.
– Robin Moffatt
Nov 11 at 11:47
It's in hub.docker.com/r/wurstmeister/kafka section "listener configuration". It's not kafka documentation, but wurstmeister docker image: " Later versions of Kafka have deprecated advertised.host.name and advertised.port. NOTE: advertised.host.name and advertised.port still work as expected, but should not be used if configuring the listeners."
– jdinunzio
Nov 11 at 12:37
Ah right. FWIW Confluent have a full set of Kafka images here: hub.docker.com/u/confluentinc
– Robin Moffatt
Nov 11 at 12:51
add a comment |
Can you link to the two docs you mention that are inconsistent? It would be good to fix them if there is an ambiguity.
– Robin Moffatt
Nov 11 at 11:47
It's in hub.docker.com/r/wurstmeister/kafka section "listener configuration". It's not kafka documentation, but wurstmeister docker image: " Later versions of Kafka have deprecated advertised.host.name and advertised.port. NOTE: advertised.host.name and advertised.port still work as expected, but should not be used if configuring the listeners."
– jdinunzio
Nov 11 at 12:37
Ah right. FWIW Confluent have a full set of Kafka images here: hub.docker.com/u/confluentinc
– Robin Moffatt
Nov 11 at 12:51
Can you link to the two docs you mention that are inconsistent? It would be good to fix them if there is an ambiguity.
– Robin Moffatt
Nov 11 at 11:47
Can you link to the two docs you mention that are inconsistent? It would be good to fix them if there is an ambiguity.
– Robin Moffatt
Nov 11 at 11:47
It's in hub.docker.com/r/wurstmeister/kafka section "listener configuration". It's not kafka documentation, but wurstmeister docker image: " Later versions of Kafka have deprecated advertised.host.name and advertised.port. NOTE: advertised.host.name and advertised.port still work as expected, but should not be used if configuring the listeners."
– jdinunzio
Nov 11 at 12:37
It's in hub.docker.com/r/wurstmeister/kafka section "listener configuration". It's not kafka documentation, but wurstmeister docker image: " Later versions of Kafka have deprecated advertised.host.name and advertised.port. NOTE: advertised.host.name and advertised.port still work as expected, but should not be used if configuring the listeners."
– jdinunzio
Nov 11 at 12:37
Ah right. FWIW Confluent have a full set of Kafka images here: hub.docker.com/u/confluentinc
– Robin Moffatt
Nov 11 at 12:51
Ah right. FWIW Confluent have a full set of Kafka images here: hub.docker.com/u/confluentinc
– Robin Moffatt
Nov 11 at 12:51
add a comment |
1 Answer
1
active
oldest
votes
up vote
2
down vote
accepted
Your config of the listeners looks correct, the problem is with your Docker Compose:
ports:
- "9094:9092"
You’re mapping 9094
(‘Outside’) back to 9092
(‘Inside’) and thus when you connect you’re connecting to the ‘Inside’ listener. If you remove this line of config then your listener set up should work as intended.
For more info, see http://rmoff.net/2018/08/02/kafka-listeners-explained/
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
accepted
Your config of the listeners looks correct, the problem is with your Docker Compose:
ports:
- "9094:9092"
You’re mapping 9094
(‘Outside’) back to 9092
(‘Inside’) and thus when you connect you’re connecting to the ‘Inside’ listener. If you remove this line of config then your listener set up should work as intended.
For more info, see http://rmoff.net/2018/08/02/kafka-listeners-explained/
add a comment |
up vote
2
down vote
accepted
Your config of the listeners looks correct, the problem is with your Docker Compose:
ports:
- "9094:9092"
You’re mapping 9094
(‘Outside’) back to 9092
(‘Inside’) and thus when you connect you’re connecting to the ‘Inside’ listener. If you remove this line of config then your listener set up should work as intended.
For more info, see http://rmoff.net/2018/08/02/kafka-listeners-explained/
add a comment |
up vote
2
down vote
accepted
up vote
2
down vote
accepted
Your config of the listeners looks correct, the problem is with your Docker Compose:
ports:
- "9094:9092"
You’re mapping 9094
(‘Outside’) back to 9092
(‘Inside’) and thus when you connect you’re connecting to the ‘Inside’ listener. If you remove this line of config then your listener set up should work as intended.
For more info, see http://rmoff.net/2018/08/02/kafka-listeners-explained/
Your config of the listeners looks correct, the problem is with your Docker Compose:
ports:
- "9094:9092"
You’re mapping 9094
(‘Outside’) back to 9092
(‘Inside’) and thus when you connect you’re connecting to the ‘Inside’ listener. If you remove this line of config then your listener set up should work as intended.
For more info, see http://rmoff.net/2018/08/02/kafka-listeners-explained/
answered Nov 11 at 11:46
Robin Moffatt
5,8181228
5,8181228
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53247553%2fkafka-access-inside-and-outside-docker%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Can you link to the two docs you mention that are inconsistent? It would be good to fix them if there is an ambiguity.
– Robin Moffatt
Nov 11 at 11:47
It's in hub.docker.com/r/wurstmeister/kafka section "listener configuration". It's not kafka documentation, but wurstmeister docker image: " Later versions of Kafka have deprecated advertised.host.name and advertised.port. NOTE: advertised.host.name and advertised.port still work as expected, but should not be used if configuring the listeners."
– jdinunzio
Nov 11 at 12:37
Ah right. FWIW Confluent have a full set of Kafka images here: hub.docker.com/u/confluentinc
– Robin Moffatt
Nov 11 at 12:51