我们有几个 DAG 处于活动状态的 Airflow 正在运行(使用 Docker compose)。上周我们将 Airflow 更新到了 2.1.3 版本。这导致我们使用 DockerOperator 的 DAG 出现错误:
airflow.exceptions.AirflowException: Invalid arguments were passed to DockerOperator (task_id: t_docker). Invalid arguments were:
**kwargs: {'volumes':
我发现这个发行说明告诉我
气流.providers.docker.operators.docker.DockerOperator 和气流.providers.docker.operators.docker_swarm.DockerSwarmOperator 中的volumes 参数被mounts 参数替换
所以我把我们的 DAG 从
t_docker = DockerOperator(
task_id='t_docker',
image='customimage:latest',
container_name='custom_1',
api_version='auto',
auto_remove=True,
volumes=['/home/airflow/scripts:/opt/airflow/scripts','/home/airflow/data:/opt/airflow/data'],
docker_url='unix://var/run/docker.sock',
network_mode='bridge',
dag=dag
)
对此
t_docker = DockerOperator(
task_id='t_docker',
image='customimage:latest',
container_name='custom_1',
api_version='auto',
auto_remove=True,
mounts=['/home/airflow/scripts:/opt/airflow/scripts','/home/airflow/data:/opt/airflow/data'],
docker_url='unix://var/run/docker.sock',
network_mode='bridge',
dag=dag
)
但现在我得到这个错误:
docker.errors.APIError: 500 Server Error for http+docker://localhost/v1.41/containers/create?name=custom_1: Internal Server Error ("json: cannot unmarshal string into Go struct field HostConfig.HostConfig.Mounts of type mount.Mount")
我究竟做错了什么?