2

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

1
  • 1
    Detail your question. What do you seek exactly? What have you tried? Commented Sep 22, 2018 at 16:55

2 Answers 2

2

We achieved to run multiple commands with DockerOperator and retrieving the logs by filling the command argument like "bash -c 'command1 && command2 && command3'".

Sign up to request clarification or add additional context in comments.

Comments

0

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

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/…
This does not work for me. Is there another way to execute multiple commands
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}
Do you get the same error with command='(echo "done") && (echo "again")?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.