我正在开发一个ETL流程,使用DockerOperator在Apache Airflow中进行调度和编排。由于我使用的是Windows笔记本电脑,所以只能从docker容器内部运行Apache Airflow。我已经成功地通过下面的docker-compose.yml文件将我的Windows笔记本电脑上的配置文件夹(下面称为
现在我想将这个带有所有内容的
根据文档,卷的左侧必须是主机上的绝对路径,在这种情况下(如果我理解正确),即为Web服务器容器(因为它为每个任务创建单独的容器)。 卷的右侧是由DockerOperator创建的任务容器内的目录。如上所述,任务容器内的“configs”文件夹确实存在,但完全为空。有人知道为什么会出现这种情况以及如何解决吗?
非常感谢您的帮助!
configs
)挂载到了airflow容器(下面称为webserver)中,并在项目根目录中指定了卷。下面是docker-compose.yml
文件中相关的代码:version: '2.1'
webserver:
build: ./docker-airflow
restart: always
privileged: true
depends_on:
- mongo
- mongo-express
environment:
- LOAD_EX=n
- EXECUTOR=Local
volumes:
- ./docker-airflow/dags:/usr/local/airflow/dags
# Volume for source code
- ./src:/src
- ./docker-airflow/workdir:/home/workdir
# configs folder as volume
- ./configs:/configs
# Mount the docker socket from the host (currently my laptop) into the webserver container so that the webserver container can create "sibbling" containers
- //var/run/docker.sock:/var/run/docker.sock # the two "//" are needed for windows OS
ports:
- 8081:8080
command: webserver
healthcheck:
test: ["CMD-SHELL", "[ -f /usr/local/airflow/airflow-webserver.pid ]"]
interval: 30s
timeout: 30s
retries: 3
networks:
- mynet
现在我想将这个带有所有内容的
configs
文件夹传递给由DockerOperator创建的容器。尽管这个configs
文件夹显然已经被挂载到了webserver容器的文件系统中,但是这个configs
文件夹是完全空的,因此我的DAG失败了。 DockerOperator的代码如下:cmd = "--config_filepath {} --data_object_name {}".format("/configs/dev.ini", some_data_object)
staging_op = DockerOperator(
command=cmd,
task_id="my_task",
image="{}/{}:{}".format(docker_hub_username, docker_hub_repo_name, image_name),
api_version="auto",
auto_remove=False,
network_mode=docker_network,
force_pull=True,
volumes=["/configs:/configs"] # "absolute_path_host:absolute_path_container"
)
根据文档,卷的左侧必须是主机上的绝对路径,在这种情况下(如果我理解正确),即为Web服务器容器(因为它为每个任务创建单独的容器)。 卷的右侧是由DockerOperator创建的任务容器内的目录。如上所述,任务容器内的“configs”文件夹确实存在,但完全为空。有人知道为什么会出现这种情况以及如何解决吗?
非常感谢您的帮助!
volumes=['C:\\Users\\kevin\\dev\\my_project\\data\\tmp:/data/tmp', 'C:\\Users\\kevin\\dev\\my_project\\data\\extracts:/data/extracts']
,但是当Airflow尝试执行这个操作符时,我收到了错误消息:500 Server Error: Internal Server Error ("invalid mode: /data/tmp")
。你有什么想法,可能是怎么发生的? - undefined/c/path/to/file
开头,而不是C:\\path\\to\\file
或者C:/path/to/file
。 - undefined