欢迎您访问365答案网,请分享给你的朋友!
生活常识 学习资料

基于Docker构建Flink镜像以LocalCluster模式运行

时间:2023-05-05
基于Docker 构建 Flink 镜像以 Local Cluster 模式运行

基本结构

编辑相关脚本

接入点脚本启动脚本Dockerflie 基于 Dockerfile 构建镜像

构建镜像运行容器查看运行状态 基本结构

flink-1.13.2:flink的服务文件docker-entrypoint.sh:接入点脚本start.sh:启动脚本Dockerflie:镜像编译文件 编辑相关脚本 接入点脚本

docker-entrypoint.sh

#!/bin/bashset -eexec "$@"

启动脚本

start.sh

#!/usr/bin/env bash./flink-1.13.2/bin/start-cluster.shwhile truedo echo "=======" sleep 60sdone

Dockerflie

#基于的基础镜像FROM java:8USER root#flink添加到根目录ADD flink-1.13.2 /flink-1.13.2ADD docker-entrypoint.sh /docker-entrypoint.shADD start.sh /start.shRUN chmod +x /docker-entrypoint.shRUN chmod +x /start.sh#设置code文件夹的工作目录WORKDIR /ENTRYPOINT ["/docker-entrypoint.sh"]CMD ["/start.sh"]EXPOSE 8081EXPOSE 6123

基于 Dockerfile 构建镜像 构建镜像

[root@xxxxxxx flink]# docker build -t flink:1.13.2 .Sending build context to Docker daemon 349.6MBStep 1/12 : FROM java:8 ---> d23bdf5b1b1bStep 2/12 : USER root ---> Running in c6dffcd2ad5cRemoving intermediate container c6dffcd2ad5c ---> bbb591a2968eStep 3/12 : ADD flink-1.13.2 /flink-1.13.2 ---> 1869d8f491acStep 4/12 : ADD docker-entrypoint.sh /docker-entrypoint.sh ---> edde936c6468Step 5/12 : ADD start.sh /start.sh ---> 41c5b36c1523Step 6/12 : RUN chmod +x /docker-entrypoint.sh ---> Running in d03ea49a93f2Removing intermediate container d03ea49a93f2 ---> bad3037aeb6aStep 7/12 : RUN chmod +x /start.sh ---> Running in 3c41dbea986cRemoving intermediate container 3c41dbea986c ---> db59c4287bb8Step 8/12 : WORKDIR / ---> Running in d8f778d77d5aRemoving intermediate container d8f778d77d5a ---> 8bf986737d13Step 9/12 : ENTRYPOINT ["/docker-entrypoint.sh"] ---> Running in 63ce34205923Removing intermediate container 63ce34205923 ---> 579e4f87b740Step 10/12 : CMD ["/start.sh"] ---> Running in 1306f0a4fda1Removing intermediate container 1306f0a4fda1 ---> de00aa0126aaStep 11/12 : EXPOSE 8081 ---> Running in 7b1de33a90fcRemoving intermediate container 7b1de33a90fc ---> b30e6e95f83bStep 12/12 : EXPOSE 6123 ---> Running in b75fa55ead17Removing intermediate container b75fa55ead17 ---> 5f86c496da25Successfully built 5f86c496da25Successfully tagged flink:1.13.2

运行容器

[root@xxxxxxx flink]# docker run -itd --name=flink -p 8081:8081 flink:1.13.2f29dcf7e830a74cb8ba087eb44808fa7fa78f1f85da47859db12ca023088b715

查看运行状态

[root@xxxxxxx flink]# docker logs flinkStarting cluster.Starting standalonesession daemon on host f29dcf7e830a.Starting taskexecutor daemon on host f29dcf7e830a.=======

访问web验证:http://localhost:8081/

Copyright © 2016-2020 www.365daan.com All Rights Reserved. 365答案网 版权所有 备案号:

部分内容来自互联网,版权归原作者所有,如有冒犯请联系我们,我们将在三个工作时内妥善处理。