Kafka setup with docker-compose

前端 未结 3 2084
盖世英雄少女心
盖世英雄少女心 2021-02-04 05:51

Hi I\'m currently setting up Kafka with Docker. I\'ve managed to setup Zookeeper and Kafka with the published confluent image, see following docker-compose file:



        
3条回答
  •  粉色の甜心
    2021-02-04 06:26

    Assuming that this is a setup intended for your local development environment, here is a solution for running in a Docker network.

    version: '2'
    
    services:
      zookeeper:
        image: confluentinc/cp-zookeeper:3.2.0
        environment:
          ZOOKEEPER_CLIENT_PORT: 2181
          ZOOKEEPER_TICK_TIME: 2000
        restart: always
        ports: ['2181:2181']
    
      kafka:
        image: confluentinc/cp-kafka:3.2.0
        depends_on:
        - zookeeper
        ports: ['29092:29092']
        environment:
          KAFKA_BROKER_ID: 1
          KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
          KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:29092,PLAINTEXT_HOST://localhost:9092
          KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
          KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
          KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
        restart: always
    
      kafka-rest:
        image: confluentinc/cp-kafka-rest:3.2.0
        depends_on:
        - kafka
        ports: ['8082:8082']
        environment:
          KAFKA_REST_ZOOKEEPER_CONNECT: 'zookeeper:2181'
          KAFKA_REST_LISTENERS: http://0.0.0.0:8082
          KAFKA_REST_SCHEMA_REGISTRY_URL: http://schema-registry:8081
          KAFKA_REST_HOST_NAME: localhost
        restart: always
    
      schema-registry:
        image: confluentinc/cp-schema-registry:3.2.0
        depends_on:
        - kafka        
        ports: ['8081:8081']
        environment:
          SCHEMA_REGISTRY_KAFKASTORE_CONNECTION_URL: 'zookeeper:2181'
          SCHEMA_REGISTRY_HOST_NAME: schema-registry
          SCHEMA_REGISTRY_LISTENERS: http://0.0.0.0:8081
        restart: always
    
      connect:
        image: confluentinc/cp-kafka-connect:3.2.0
        depends_on:
        - zookeeper
        - kafka
        - schema-registry
        ports: ['8083:8083']
        restart: always
        environment:
          CONNECT_BOOTSTRAP_SERVERS: 'kafka:29092'
          CONNECT_REST_ADVERTISED_HOST_NAME: connect
          CONNECT_REST_PORT: 8083
          CONNECT_GROUP_ID: compose-connect-group
          CONNECT_CONFIG_STORAGE_TOPIC: docker-connect-configs
          CONNECT_OFFSET_STORAGE_TOPIC: docker-connect-offsets
          CONNECT_STATUS_STORAGE_TOPIC: docker-connect-status
          CONNECT_KEY_CONVERTER: io.confluent.connect.avro.AvroConverter
          CONNECT_KEY_CONVERTER_SCHEMA_REGISTRY_URL: http://schema-registry:8081
          CONNECT_VALUE_CONVERTER: io.confluent.connect.avro.AvroConverter
          CONNECT_VALUE_CONVERTER_SCHEMA_REGISTRY_URL: http://schema-registry:8081
          CONNECT_INTERNAL_KEY_CONVERTER: org.apache.kafka.connect.json.JsonConverter
          CONNECT_INTERNAL_VALUE_CONVERTER: org.apache.kafka.connect.json.JsonConverter
          CONNECT_ZOOKEEPER_CONNECT: "zookeeper:2181"
    

    Updated here - https://github.com/confluentinc/examples/blob/5.3.1-post/cp-all-in-one/docker-compose.yml

提交回复
热议问题