1. 编辑相关脚本
1.1 接入点脚本
docker-entrypoint.sh
#!/bin/bash
set -e
exec "$@"
1.2 启动脚本
start.sh
#!/usr/bin/env bash
bin/start-cluster.sh
while true
do
echo "======="
sleep 60s
done
1.3 Dockerfile
FROM lynn/jdk:1.8.0_172
LABEL maintainer="Lynn Yuan <longjianzhiyun@163.com>"
ENV FLINK_HOME /flink
ENV FLINK_VERSION 1.7.1
ENV HADOOP_VERSION 27
ENV TAR flink-${FLINK_VERSION}-bin-hadoop${HADOOP_VERSION}-scala_2.11.tgz
ENV TAR_URL http://mirrors.hust.edu.cn/apache/flink/flink-${FLINK_VERSION}/${TAR}
ENV PATH ${FLINK_HOME}/bin:$PATH
RUN set -x \
&& apt-get update \
&& apt-get install -y wget vim curl net-tools telnet procps nmap\
&& wget ${TAR_URL}
RUN set -x \
&& mkdir ${FLINK_HOME}\
&& tar zxvf ${TAR} -C ${FLINK_HOME} \
&& mv ${FLINK_HOME}/flink-${FLINK_VERSION}/* ${FLINK_HOME} \
&& rm -rf ${FLINK_HOME}/flink-${FLINK_VERSION} \
&& rm -rf ${TAR}
ADD docker-entrypoint.sh /docker-entrypoint.sh
ADD start.sh /start.sh
RUN set -x \
&& chmod +x /docker-entrypoint.sh \
&& chmod +x /start.sh
WORKDIR ${FLINK_HOME}
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["/start.sh"]
EXPOSE 8081
EXPOSE 6123
2. 使用Dockerfile build image
docker build --rm -t lynn/flink:1.7.1 .
3. 运行容器
docker run -idt --name=flink --hostname flink-node -p 18081:8081 lynn/flink:1.7.1
在浏览器中输入如下Url:
http://localhost:18081/
截图如下:
转载于:https://blog.51cto.com/1196740/2335133