1,编写服务编排配置文件 docker-compose-storm.yml
version: '3.1' services: zookeeper: image: zookeeper container_name: zookeeper restart: always kafka: image: michaeldqin/kafka container_name: kafka depends_on: - zookeeper links: - zookeeper volumes: - ./data:/data ports: - 9092:9092 environment: KAFKA_BROKER_NO: 1 KAFKA_ZOOKEEPER_CONNECT: zookeeper KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092 ui: image: storm:1.1 command: storm ui restart: always depends_on: - nimbus links: - nimbus container_name: ui ports: - 8090:8080 nimbus: image: storm:1.1 command: storm nimbus restart: always volumes: - /www/storm/data:/data - /www/logs/storm:/logs depends_on: - zookeeper links: - zookeeper - kafka container_name: nimbus ports: - 6627:6627 supervisor: image: storm:1.1 command: storm supervisor restart: always volumes: - /www/storm/data:/data - /www/logs/storm:/logs depends_on: - nimbus - zookeeper links: - nimbus - zookeeper - kafka container_name: supervisor
说明:
(1)使用服务编排模式,大大简化了搭建的过程,否则我们要先搭建一个 zookeeper, 然后启动 kafka,启动 storm nibus,启动 storm supervisor,storm ui 等组件,它可以让各个组件在隔离环境运行
(2)具体说明,可查阅官网 https://beta.docs.docker.com/samples/library/storm/
2, 安装 Compose
从 Github 上下载它的二进制包来使用,最新发行的版本地址:https://github.com/docker/compose/releases。
运行以下命令以下载 Docker Compose 的当前稳定版本:
$ sudo curl -L "https://github.com/docker/compose/releases/download/1.24.1/docker-compose-$(uname -s)-$(uname -m)" -o
/usr/local/bin/docker-compose
如果要安装其他版本的 Compose,请替换 1.24.1。
将可执行权限应用于二进制文件:
$ sudo chmod +x /usr/local/bin/docker-compose
创建软链:
$ sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
测试是否安装成功:
$ docker-compose --version
cker-compose version 1.24.1, build 4667896b
3,使用 compose 构建和运行应用
docker-compose -f stack.yml up -d
-d:后台运行
说明:
(1) compose 的具体使用,可查阅 https://www.runoob.com/docker/docker-compose.html
作者:magic_kid_2010