To define and utilize the host name for Kafka within a Docker Compose setup, follow these steps:
docker-compose.yml
file and define the environment variable for the Kafka broker host name:environment:
KAFKA_ADVERTISED_HOST_NAME: "kafka"
docker-compose.yml
file:kafka:
image: wurstmeister/kafka:latest
ports:
- "9092:9092"
environment:
KAFKA_ADVERTISED_HOST_NAME: "kafka"
networks:
my_network:
driver: bridge
KAFKA_ADVERTISED_LISTENERS
environment variable in the Kafka service:environment:
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
networks:
my_network:
aliases:
- myapp
depends_on:
- kafka
kafka
in the configuration of the Kafka clients to connect to the Kafka broker on the Docker network:bootstrap.servers=kafka:9092
Note: Make sure to replace myapp
with your application name, and zookeeper:2181
with the actual Zookeeper connection string.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2022-09-20 11:00:00 +0000
Seen: 1 times
Last updated: Dec 27 '22
How can I deal with Expression.Error related to a column in Power Query?
How can you implement pagination in Oracle for the LISTAGG() function?
What is the process for implementing a FutureBuilder on an OnTap function in Flutter?
How can we require users to be logged in before they can access the root folders in WordPress?
In SCSS, what is the method for grouping and reusing a set of classes and styles?
How can popen() be used to direct streaming data to TAR?
How does iOS retrieve information from a BLE device?
How can Django Admin accommodate a variety of formats and locales for its input fields?