使用Docker快速部署Airflow服务

/ Linux服务安装搭建Docker / 没有评论 / 241浏览

Dockerfile

这里的基础镜像是我做好基础优化的,编译安装,时间和编码问题解决,带有tmux和vim等命令,便于debug

[root@shangzheng-test ~]# cat airflow.file
FROM python3.6
ADD ./run.sh /opt
ADD ./run2.sh /opt
ARG TZ="Asia/Shanghai"
ENV TZ ${TZ}
ADD  ./shanghai /etc/localtime
WORKDIR /opt
RUN  export AIRFLOW_HOME=~/airflow \
     && apt-get -y update && apt-get -y install htop tmux vim tzdata && echo 'Asia/Shanghai' >/etc/timezone && dpkg-reconfigure -f noninteractive tzdata \
     && pip install apache-airflow \
     && airflow initdb  \
     && rm -rf /var/lib/apt/lists/* \
     && rm -rf /var/cache/*
     
[root@shangzheng-test ~]# cat run.sh
#! /bin/bash
airflow scheduler

[root@shangzheng-test ~]# cat run2.sh
#! /bin/bash
airflow webserver -p 8080

run docker

需要进入容器依次启动两个服务,然后tmux挂起

root@nsdk2:~# docker run -tid -p 8080:8080 --name airflow you_url/devops/py_airflow:en_US.UTF-8
root@nsdk2:~# docker exec -ti airflow /bin/bash
root@97d8ec61bccd:/opt# ll
total 16
drwxr-xr-x 1 root root 4096 Jun  4 18:56 ./
drwxr-xr-x 1 root root 4096 Jun  4 19:14 ../
-rwxr-xr-x 1 root root   31 Jun  4 18:55 run2.sh*
-rwxr-xr-x 1 root root   39 Jun  4 18:55 run.sh*
root@97d8ec61bccd:/opt# tmux
bash run.sh
[detached (from session 0)]
root@97d8ec61bccd:/opt# tmux
bash run2.sh

demo