我们有气流运行(使用码头组合)和几个DAG的活动。上周,我们将气流更新为2.1.3版。这导致使用DockerOperator的DAG出现错误:
airflow.exceptions.AirflowException: Invalid arguments were passed to DockerOperator (task_id: t_docker). Invalid arguments were:
**kwargs: {'volumes':我发现这个释放说明告诉我
将airflow.providers.docker.operators.docker.DockerOperator和airflow.providers.docker.operators.docker_swarm.DockerSwarmOperator中的卷参数替换为挂载参数。
所以我改变了我们的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")我做错了什么?
发布于 2021-09-11 15:56:02
更改不仅在参数名称中,而且也是对装入语法的更改。
你应该换掉
volumes=['/home/airflow/scripts:/opt/airflow/scripts','/home/airflow/data:/opt/airflow/data']通过以下方式:
mounts=[
Mount(source="/home/airflow/scripts", target="/opt/airflow/scripts", type="bind"),
Mount(source="/home/airflow/data", target="/opt/airflow/data", type="bind"),
]所以你的代码是:
from docker.types import Mount
t_docker = DockerOperator(
task_id='t_docker',
image='customimage:latest',
container_name='custom_1',
api_version='auto',
auto_remove=True,
mounts=[
Mount(source="/home/airflow/scripts", target="/opt/airflow/scripts", type="bind"),
Mount(source="/home/airflow/data", target="/opt/airflow/data", type="bind"),
],
docker_url='unix://var/run/docker.sock',
network_mode='bridge',
dag=dag
)https://stackoverflow.com/questions/69132362
复制相似问题