-
-
Save tridungle/6d294ae2d2678b323a5119536325b8ca to your computer and use it in GitHub Desktop.
DockerOperator illustration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from airflow import DAG | |
from airflow.operators.docker_operator import DockerOperator | |
dag = DAG(dag_id="example DAG", default_args=default_args) | |
run_task_with_docker = DockerOperator( | |
task_id='run_task_with_docker', | |
# Assuming this image is already pulled | |
image='organization/node-worker', | |
api_version='auto', | |
environment={ | |
'NODE_VAR1': "value1" | |
'NODE_VAR2': "value2" | |
}, | |
volumes=[ | |
"/home/ubuntu/res:/root/res" | |
], | |
# Run a specific command if needed | |
command='node service run', | |
# The local API url we've setup earlier | |
docker_url='tcp://0.0.0.0:2376', | |
# If needed | |
network_mode='bridge', | |
dag=dag | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment