How to do it...

We will use Docker Compose to orchestrate Kafka. Go ahead and create a new YML file called docker-compose-kafka.yml directly under the geolocation project. Then, add the following snippet to the newly created Docker Compose file:

version: "2" 
 
services: 
  zookeeper: 
    image: wurstmeister/zookeeper 
    ports: 
      - "2181:2181" 
       
  kafka: 
    image: wurstmeister/kafka:0.10.1.0-1 
    ports: 
      - "9092:9092" 
    environment: 
      KAFKA_ADVERTISED_HOST_NAME: 192.168.99.100 
      KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181 
    volumes: 
      - /var/run/docker.sock:/var/run/docker.sock 

As you can see, we have not used any official images. At the time of writing this, there is no official image for Kafka. However, there are Kafka images listed under the Confluent organization in Docker Hub. Confluent ...

Get Microservices Deployment Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.