Aim

In this post we will be installing Kafka using docker compose

Prerequisite

  • You need to have docker installed on your machine
  • You need to have docker-compose installed on your machine

Step 1 : Create a yaml file

touch docker-compose.yaml

Step 2 : Put the below contents in the docker compose file

version: "3"
services:
  zookeeper:
    image: wurstmeister/zookeeper
    container_name: zookeeper
    ports:
    - 2181:2181

  kafka:
    image: wurstmeister/kafka
    container_name: kafka
    ports:
    - 9092:9092
    environment:
      KAFKA_ADVERTISED_HOST_NAME: localhost
      KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181

Step 3 : Start the service

  • You can start the service in foreground mode using
docker-compose -f docker-compose.yml up
  • If you want to start the service in background mode then you can use the below command
docker-compose -f docker-compose.yml up -d
4.3 4 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x