-
拉取zookeeper 镜像
docker pull wurstmeister/zookeeper
-
创建并启动容器
docker run --name zookeeper -p 2181:2181 -V /etc/localtime:/etc/localtime -d wurstmeister/zookeeper
#查看启动的容器 docker ps
-
拉取kafka
docker pull wurstmeister/zookeeper
-
创建并启动kafka容器
docker run -p 9092:9092 --name kafka -e KAFKA_BROKER_ID=0 -e KAFKA_ZOOKEEPER_CONNECT=192.168.108.129:2181/kafka -e KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://192.168.108.129:9092 -e KAFKA_LISTENERS=PLAINTEXT://0.0.0.0:9092 -v /etc/localtime:/etc/localtime -d wurstmeister/kafka
-
进入交互式容器打开kafka server
docker exec -it kafka bash /opt/kafka_2.13-2.6.0/bin/zookeeper-server-start.sh /opt/kafka_2.13-2.6.0/config/zookeeper.properties &