vim docker-compose.yml
version: '3' services: zookeeper: image: zookeeper ports: - 2182:2181 restart: always kafka1: image: wurstmeister/kafka container_name: kafka1 ports: - "9093:9092" environment: KAFKA_BROKER_ID: 0 KAFKA_NUM_PARTITIONS: 3 KAFKA_DEFAULT_REPLICATION_FACTOR: 2 KAFKA_ZOOKEEPER_CONNECT: 10.68.4.1:2182 KAFKA_LISTENERS: PLAINTEXT://0.0.0.0:9092 KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://10.68.4.1:9093 volumes: - /data/docker-compose/kafka/broker1/logs:/opt/kafka/logs - /var/run/docker.sock:/var/run/docker.sock restart: always kafka2: image: wurstmeister/kafka container_name: kafka2 ports: - "9094:9092" environment: KAFKA_BROKER_ID: 1 KAFKA_NUM_PARTITIONS: 3 KAFKA_DEFAULT_REPLICATION_FACTOR: 2 KAFKA_ZOOKEEPER_CONNECT: 10.68.4.1:2182 KAFKA_LISTENERS: PLAINTEXT://0.0.0.0:9092 KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://10.68.4.1:9094 volumes: - /data/docker-compose/kafka/broker2/logs:/opt/kafka/logs - /var/run/docker.sock:/var/run/docker.sock restart: always kafka3: image: wurstmeister/kafka container_name: kafka3 ports: - "9095:9092" environment: KAFKA_BROKER_ID: 2 KAFKA_NUM_PARTITIONS: 3 KAFKA_DEFAULT_REPLICATION_FACTOR: 2 KAFKA_ZOOKEEPER_CONNECT: 10.68.4.1:2182 KAFKA_LISTENERS: PLAINTEXT://0.0.0.0:9092 KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://10.68.4.1:9095 volumes: - /data/docker-compose/kafka/broker3/logs:/opt/kafka/logs - /var/run/docker.sock:/var/run/docker.sock restart: always
2、启动服务
docker-compose up -d
标签:compose,logs,0.0,KAFKA,docker,kafka From: https://www.cnblogs.com/linjiangCN/p/17001768.html