docker-compose 创建kafka服务

docker-compose 创建kafka服务

1.创建 docker-compose.yml 

2. docker-compose.yml 内容

 zookeeper:
   restart: always
   container_name: zookeeper
   image: wurstmeister/zookeeper
   ports:
     - 2181:2181
 kafka:
   restart: always
   container_name: kafka
   image: wurstmeister/kafka
   ports:
     - 9092:9092 
   depends_on:
     - zookeeper
   links:
     - zookeeper
   environment:
     KAFKA_ADVERTISED_HOST_NAME: ${localhost}
     KAFKA_ZOOKEEPER_CONNECT: ${localhost}:2181
   volumes:
     - /var/run/docker.sock:/var/run/docker.sock
     - /home/services/kafka-config/server.properties:/opt/kafka/config/server.properties//这里是为了方便以后修改配置 映射出来的文件

3.使用 docker-compose 命令启动服务

$ docker-compose up -d

4. 测试是否安装 

 

$ docker exec kafka /bin/bash //进入终端
bash-4.3# ls
bin  etc   kafka  lib64  mnt  proc  run   srv  tmp  var
dev  home  lib    media  opt  root  sbin  sys  usr
bash-4.3#

 

你可能感兴趣的:(docker)