docker-compose.yml
version: "3.0"services: zookeeper: image: wurstmeister/zookeeper container_name: zookeeper restart: always ports: - 2181:2181 kafka: image: wurstmeister/kafka container_name: kafka ports: - 9092:9092 environment: # client要访问的broker地址 KAFKA_ADVERTISED_HOST_NAME: kafka # 通过端口连接 zookeeper KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181 restart: always volumes: - ./docker.sock:/var/run/docker.sock