Skip to content

Instantly share code, notes, and snippets.

@anteverse
Created February 13, 2020 13:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save anteverse/cf05e677da591690bfeed448eb9bb767 to your computer and use it in GitHub Desktop.
Save anteverse/cf05e677da591690bfeed448eb9bb767 to your computer and use it in GitHub Desktop.
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