利用 docker-compose 搭建kafka&redis&zookeeper

version: "2"

services:
  zookeeper:
    image: zookeeper:3.4.9
    container_name: zookeeper
    hostname: zookeeper
    ports:
      - "2181:2181"
    volumes:
      - "zookeeper_data1:/data"
    environment:
      ZOO_MY_ID: 1
      ZOO_PORT: 2181
      ZOO_SERVERS: server.1=zoo1:2888:3888
  kafka:
    image: confluentinc/cp-kafka:5.3.1
    container_name: broker
    hostname: broker
    ports:
      - "9092:9092"
    volumes:
      - "kafka1_data:/var/lib/kafka/data"
    environment:
      KAFKA_ENABLE_DELETE_TOPICS: "true"
      KAFKA_CREATE_TOPICS: "test"
      KAFKA_ADVERTISED_LISTENERS: LISTENER_DOCKER_INTERNAL://broker:19092,LISTENER_DOCKER_EXTERNAL://${DOCKER_HOST_IP:-127.0.0.1}:9092
      KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: LISTENER_DOCKER_INTERNAL:PLAINTEXT,LISTENER_DOCKER_EXTERNAL:PLAINTEXT
      KAFKA_INTER_BROKER_LISTENER_NAME: LISTENER_DOCKER_INTERNAL
      KAFKA_ZOOKEEPER_CONNECT: "zookeeper:2181"
      KAFKA_BROKER_ID: 1
      KAFKA_LOG4J_LOGGERS: "kafka.controller=INFO,kafka.producer.async.DefaultEventHandler=INFO,state.change.logger=INFO"
      KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
    depends_on:
      - zookeeper
  redis:
    image: redis
    ports:
      - "31001:6379"


volumes:
  zookeeper_data1:
    driver: local
  kafka1_data:
    driver: local

你可能感兴趣的:(kafka,java-zookeeper,docker)