docker容器单机部署zookeeper+kafka集群

bash 复制代码
version: '2.2'
services:
  zookeeper:
    image: zookeeper:3.6.3
    ports:
      - "2181:2181"
    restart: always
  kafka1:
    image: bitnami/kafka:2.1.0
    depends_on: [ zookeeper ]
    container_name: kafka1
    ports:
      - "9091:9091"
    environment:
      HOSTNAME: kafka1
      KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka1:9091
      KAFKA_LISTENERS: PLAINTEXT://0.0.0.0:9091
      KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
      ALLOW_PLAINTEXT_LISTENER: "yes"
    extra_hosts:
      kafka1: 10.21.214.66
  kafka2:
    image: bitnami/kafka:2.1.0
    depends_on: [ zookeeper ]
    container_name: kafka2
    ports:
      - "9092:9092"
    environment:
      HOSTNAME: kafka2
      KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka2:9092
      KAFKA_LISTENERS: PLAINTEXT://0.0.0.0:9092
      KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
      ALLOW_PLAINTEXT_LISTENER: "yes"
    extra_hosts:
      kafka2: 10.21.214.66
  kafka3:
    image: bitnami/kafka:2.1.0
    depends_on: [ zookeeper ]
    container_name: kafka3
    ports:
      - "9093:9093"
    environment:
      HOSTNAME: kafka3
      KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka3:9093
      KAFKA_LISTENERS: PLAINTEXT://0.0.0.0:9093
      KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
      ALLOW_PLAINTEXT_LISTENER: "yes"
    extra_hosts:
      kafka3: 10.21.214.66

KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181 其中zookeeper会转化成zookeeper的ip

kafka1: 10.21.214.66 其中10.21.214.66 填写宿主机ip

相关推荐
sauTCc7 小时前
Docker初探
docker
c无序7 小时前
【Docker-7】Docker是什么+Docker版本+Docker架构+Docker生态
docker·容器·架构
FixBug_Nick7 小时前
使用Docker安装及使用最新版本的Jenkins
docker·容器·jenkins
IT成长日记8 小时前
【Kafka基础】Kafka工作原理解析
分布式·kafka
州周10 小时前
kafka副本同步时HW和LEO
分布式·kafka
Zero_to_zero123410 小时前
解决docker的ubuntu系统中文乱码问题
ubuntu·docker·容器
@郭小茶10 小时前
docker-compose方式部署docker项目
运维·docker·容器
程序媛学姐11 小时前
SpringKafka错误处理:重试机制与死信队列
java·开发语言·spring·kafka
程序员 小柴12 小时前
docker的与使用
java·docker·eureka
ghostwritten13 小时前
Docker Registry Clean
运维·docker·容器