github.com/hoveychen/kafka-go@v0.4.42/docker-compose-241.yml (about)

     1  version: "3"
     2  services:
     3    kafka:
     4      image: wurstmeister/kafka:2.12-2.4.1
     5      restart: on-failure:3
     6      links:
     7      - zookeeper
     8      ports:
     9      - 9092:9092
    10      - 9093:9093
    11      environment:
    12        KAFKA_VERSION: '2.4.1'
    13        KAFKA_BROKER_ID: '1'
    14        KAFKA_CREATE_TOPICS: 'test-writer-0:3:1,test-writer-1:3:1'
    15        KAFKA_DELETE_TOPIC_ENABLE: 'true'
    16        KAFKA_ADVERTISED_HOST_NAME: 'localhost'
    17        KAFKA_ADVERTISED_PORT: '9092'
    18        KAFKA_ZOOKEEPER_CONNECT: 'zookeeper:2181'
    19        KAFKA_AUTO_CREATE_TOPICS_ENABLE: 'true'
    20        KAFKA_MESSAGE_MAX_BYTES: '200000000'
    21        KAFKA_LISTENERS: 'PLAINTEXT://:9092,SASL_PLAINTEXT://:9093'
    22        KAFKA_ADVERTISED_LISTENERS: 'PLAINTEXT://localhost:9092,SASL_PLAINTEXT://localhost:9093'
    23        KAFKA_SASL_ENABLED_MECHANISMS: 'PLAIN,SCRAM-SHA-256,SCRAM-SHA-512'
    24        KAFKA_OPTS: "-Djava.security.auth.login.config=/opt/kafka/config/kafka_server_jaas.conf"
    25        CUSTOM_INIT_SCRIPT: |-
    26          echo -e 'KafkaServer {\norg.apache.kafka.common.security.scram.ScramLoginModule required\n username="adminscram"\n password="admin-secret";\n org.apache.kafka.common.security.plain.PlainLoginModule required\n username="adminplain"\n password="admin-secret"\n user_adminplain="admin-secret";\n  };' > /opt/kafka/config/kafka_server_jaas.conf;
    27          /opt/kafka/bin/kafka-configs.sh --zookeeper zookeeper:2181 --alter --add-config 'SCRAM-SHA-256=[password=admin-secret-256],SCRAM-SHA-512=[password=admin-secret-512]' --entity-type users --entity-name adminscram
    28  
    29    zookeeper:
    30      image: wurstmeister/zookeeper
    31      ports:
    32      - 2181:2181