Syntax to pass multiple commands (consisting of bash and python ) to the command parameter in DockerOperator For example if I have mix of command like -> python test.py , mkdir -p /test to be executed inside the docker container
2 Answers
Pass multiple commands to the command parameter separated by &&, like this:
command='(command1) && (command2) && (command3)'
So the full code looks like:
t_docker = DockerOperator(
task_id='docker_command',
image='bde2020/spark-master:latest',
api_version='auto',
auto_remove=True,
command='(python a.py) && (echo "done") && (mkdir /mydirectory) && (echo "directory created"))',
network_mode='bridge'
)
4 Comments
akki
There seems to be a bug because of which it does not take list input, I just reported it here - issues.apache.org/jira/browse/…
andresg3
This does not work for me. Is there another way to execute multiple commands
andresg3
I tried: command='(echo "done") && (spark-submit --master local[*] /home/jovyan/pyspark_test01.py)' But got error: ERROR - docker container failed: {'Error': None, 'StatusCode': 127}
akki
Do you get the same error with
command='(echo "done") && (echo "again")?