docker 部署 kafka
镜像使用 bitnami/zookeeper
注意 KAFKA_CFG_LISTENERS 为在容器中绑定的地址和端口
KAFKA_CFG_ADVERTISED_LISTENERS 为映射到容器外的地址和端口。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
| version: "3" services: zookeeper: image: 'bitnami/zookeeper:latest' ports: - '2181:2181' environment: - ALLOW_ANONYMOUS_LOGIN=yes volumes: - ./zookeeper:/bitnami/zookeeper networks: kafka_net: aliases: - zookeeper
kafka: image: 'bitnami/kafka:latest' ports: - '9092:9092' environment: - KAFKA_BROKER_ID=1 - KAFKA_CFG_LISTENERS=PLAINTEXT://0.0.0.0:9092 - KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://IP:9092 - KAFKA_CFG_ZOOKEEPER_CONNECT=zookeeper:2181 - ALLOW_PLAINTEXT_LISTENER=yes - KAFKA_CFG_LOG_RETENTION_HOURS=6 volumes: - ./kafka:/bitnami/kafka depends_on: - zookeeper networks: kafka_net: aliases: - kafka
kafka2: image: 'bitnami/kafka:latest' ports: - '9093:9093' environment: - KAFKA_BROKER_ID=2 - KAFKA_CFG_LISTENERS=PLAINTEXT://0.0.0.0:9093 - KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://IP:9093 - KAFKA_CFG_ZOOKEEPER_CONNECT=zookeeper:2181 - ALLOW_PLAINTEXT_LISTENER=yes - KAFKA_CFG_LOG_RETENTION_HOURS=6 volumes: - ./kafka2:/bitnami/kafka depends_on: - zookeeper networks: kafka_net: aliases: - kafka2
kafka3: image: 'bitnami/kafka:latest' ports: - '9094:9094' environment: - KAFKA_BROKER_ID=3 - KAFKA_CFG_LISTENERS=PLAINTEXT://0.0.0.0:9094 - KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://IP:9094 - KAFKA_CFG_ZOOKEEPER_CONNECT=zookeeper:2181 - ALLOW_PLAINTEXT_LISTENER=yes - KAFKA_CFG_LOG_RETENTION_HOURS=6 volumes: - ./kafka3:/bitnami/kafka depends_on: - zookeeper networks: kafka_net: aliases: - kafka3
kafka_manager: image: 'hlebalbau/kafka-manager:latest' ports: - "9002:9000" environment: ZK_HOSTS: "zookeeper:2181" APPLICATION_SECRET: letmein depends_on: - zookeeper - kafka - kafka2 - kafka3 networks: kafka_net: aliases: - kafka_manager
networks: kafka_net:
|