Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
DockerOperator illustration
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
You can’t perform that action at this time.