Docker 本地容器搭建zk、kakfa
编辑docker-compose文件
version: '2'
networks:
zk:
driver: bridge
services:
zoo1:
image: zookeeper
restart: always
container_name: zoo1
hostname: zoo1
ports:
- "2181:2181"
environment:
ZOO_MY_ID: 1
ZOO_SERVERS: server.1=0.0.0.0:2888:3888;2181 server.2=zoo2:2888:3888;2181 server.3=zoo3:2888:3888;2181
networks:
- zk
zoo2:
image: zookeeper
restart: always
container_name: zoo2
hostname: zoo2
ports:
- "2182:2181"
environment:
ZOO_MY_ID: 2
ZOO_SERVERS: server.1=zoo1:2888:3888;2181 server.2=0.0.0.0:2888:3888;2181 server.3=zoo3:2888:3888;2181
networks:
- zk
zoo3:
image: zookeeper
restart: always
container_name: zoo3
hostname: zoo3
ports:
- "2183:2181"
environment:
ZOO_MY_ID: 3
ZOO_SERVERS: server.1=zoo1:2888:3888;2181 server.2=zoo2:2888:3888;2181 server.3=0.0.0.0:2888:3888;2181
networks:
- zk
kafka1:
image: wurstmeister/kafka:0.8.2.2
restart: always
container_name: kafka1
hostname: 10.59.95.67
ports:
- 9092:9092
environment:
KAFKA_BROKER_ID: "1"
KAFKA_LISTENERS: PLAINTEXT://:9092
KAFKA_ADVERTISED_port: 9092
KAFKA_ZOOKEEPER_CONNECT: zoo1:2181,zoo2:2181,zoo3:2181
KAFKA_LOG_RETENTION_HOURS: 48
KAFKA_DELETE_TOPIC_ENABLE: "true"
networks:
- zk
kafka2:
image: wurstmeister/kafka:0.8.2.2
restart: always
container_name: kafka2
hostname: 10.59.95.67
ports:
- 9093:9093
environment:
KAFKA_BROKER_ID: "2"
KAFKA_LISTENERS: PLAINTEXT://:9093
KAFKA_ADVERTISED_port: 9093
KAFKA_ZOOKEEPER_CONNECT: zoo1:2181,zoo2:2181,zoo3:2181
KAFKA_LOG_RETENTION_HOURS: 48
KAFKA_DELETE_TOPIC_ENABLE: "true"
networks:
- zk
kafka3:
image: wurstmeister/kafka:0.8.2.2
restart: always
container_name: kafka3
hostname: 10.59.95.67
ports:
- 9094:9094
environment:
KAFKA_BROKER_ID: "3"
KAFKA_LISTENERS: PLAINTEXT://:9094
KAFKA_ADVERTISED_port: 9094
KAFKA_ZOOKEEPER_CONNECT: zoo1:2181,zoo2:2181,zoo3:2181
KAFKA_LOG_RETENTION_HOURS: 48
KAFKA_DELETE_TOPIC_ENABLE: "true"
networks:
- zk
docker-compose命令启动