$ git clone https://github.com/wurstmeister/kafka-docker.git
docker-compose-single-broker.yml
의 설정을 바꾼다
KAFKA_ADVERTISED_HOST_NAME
을 127.0.0.1 (로컬호스트) 로 변경한다docker-compose -f docker-compose-single-broker.yml up -d
docker ps
로 실행되고 있는 컨테이너 확인zookeeper
와 kafka
두개가 띄워져 있어야 한다CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
4596bda0943c kafka-docker_kafka "start-kafka.sh" 2 hours ago Up 2 hours 0.0.0.0:9092->9092/tcp kafka-docker_kafka_1
0db297026525 wurstmeister/zookeeper "/bin/sh -c '/usr/sb…" 2 hours ago Up 2 hours 22/tcp, 2888/tcp, 3888/tcp, 0.0.0.0:2181->2181/tcp kafka-docker_zookeeper_1
docker exec -t 4596 kafka-topics.sh --bootstrap-server localhost:9092 --create --topic test
test
라는 토픽을 생성했다
docker exec -it 4596 kafka-console-producer.sh --topic test --broker-list localhost:9092
test
라는 토픽명으로 메시지를 전달하게 되는 것hello world
kafka
docker exec -it 4596 kafka-console-consumer.sh --topic test --bootstrap-server localhost:9092
hello world
kafka