老郑的博客

木叶飞舞之处,火亦生生不息!

docker-compose启动kafka

文件如下



version: "3"
services:
   zookeeper:
     image: zookeeper
     container_name: zookeeper
    
     ports: 
      - 2181:2181
     networks:
      - kafkanetwork 
     volumes:
      - zookeeper_data:/data
      - zookeeper_log:/logs
      - zookeeper_datalog:/datalog
      - /etc/localtime:/etc/localtime
     deploy: 
         restart_policy:
             condition: on-failure 
   kafka:
     image: wurstmeister/kafka
     ports:
      - 9092:9092
     environment:
      KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
      KAFKA_LISTENERS: PLAINTEXT://kafka:9092
      KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://localhost:9092  
      KAFKA_BROKER_ID: 22
     volumes:
       - /etc/localtime:/etc/localtime
       - kafka_config:/opt/kafka/config/
       - kafka_libs:/opt/kafka/libs/
       - kafka_logs:/kafka
     networks: 
       - kafkanetwork
     container_name: kafka
     deploy:  
      restart_policy:
          condition: on-failure
   kafka-manager:
    image: sheepkiller/kafka-manager:latest
    ports: 
     - 9000:9000
    environment:
     ZK_HOSTS: zookeeper:2181
     APPLICATION_SECRET: LETMEIN
     KM_ARGS: -Djava.net.preferIPv4Stack=true
    networks: 
     - kafkanetwork
    deploy:  
      restart_policy:
          condition: on-failure
networks:
   kafkanetwork:
     external:
        name: kafkanetwork

volumes:
   zookeeper_data: {}
   zookeeper_log: {}
   zookeeper_datalog: {}
   kafka_config: {}
   kafka_libs: {}
   kafka_logs: {}
  
posted @ 2021-03-12 21:42  zyz1  阅读(369)  评论(0编辑  收藏  举报