Signup/Sign In
Ask Question
Not satisfied by the Answer? Still looking for a better solution?

How to run multiple commands in docker at once

I'm trying to execute multiple commands like this.

docker run image cd /some/path && python a.py

But I get a "No such file or directory" error.
by

10 Answers

espadacoder11
In order to run multiple commands in docker, use /bin/bash -c with a semicolon ;

docker run image /bin/bash -c "cd /some/path; python a.py"

In this case the second command (python) will be executed only if the first command (cd) returns no error or an exit status. To avoid this use && instead of ; (semi-colon)

docker run image /bin/bash -c "cd /some/path && python a.py"
espadacoder11
In order to run multiple commands in docker, use /bin/bash -c with a semicolon ;

docker run image /bin/bash -c "cd /some/path; python a.py"

In this case the second command (python) will be executed only if the first command (cd) returns no error or an exit status. To avoid this use && instead of ; (semi-colon)

docker run image /bin/bash -c "cd /some/path && python a.py"
espadacoder11
In order to run multiple commands in docker, use /bin/bash -c with a semicolon ;

docker run image /bin/bash -c "cd /some/path; python a.py"

In this case the second command (python) will be executed only if the first command (cd) returns no error or an exit status. To avoid this use && instead of ; (semi-colon)

docker run image /bin/bash -c "cd /some/path && python a.py"
espadacoder11
In order to run multiple commands in docker, use /bin/bash -c with a semicolon ;

docker run image /bin/bash -c "cd /some/path; python a.py"

In this case the second command (python) will be executed only if the first command (cd) returns no error or an exit status. To avoid this use && instead of ; (semi-colon)

docker run image /bin/bash -c "cd /some/path && python a.py"
espadacoder11
In order to run multiple commands in docker, use /bin/bash -c with a semicolon ;

docker run image /bin/bash -c "cd /some/path; python a.py"

In this case the second command (python) will be executed only if the first command (cd) returns no error or an exit status. To avoid this use && instead of ; (semi-colon)

docker run image /bin/bash -c "cd /some/path && python a.py"
espadacoder11
In order to run multiple commands in docker, use /bin/bash -c with a semicolon ;

docker run image /bin/bash -c "cd /some/path; python a.py"

In this case the second command (python) will be executed only if the first command (cd) returns no error or an exit status. To avoid this use && instead of ; (semi-colon)

docker run image /bin/bash -c "cd /some/path && python a.py"
espadacoder11
In order to run multiple commands in docker, use /bin/bash -c with a semicolon ;

docker run image /bin/bash -c "cd /some/path; python a.py"

In this case the second command (python) will be executed only if the first command (cd) returns no error or an exit status. To avoid this use && instead of ; (semi-colon)

docker run image /bin/bash -c "cd /some/path && python a.py"
espadacoder11
In order to run multiple commands in docker, use /bin/bash -c with a semicolon ;

docker run image /bin/bash -c "cd /some/path; python a.py"

In this case the second command (python) will be executed only if the first command (cd) returns no error or an exit status. To avoid this use && instead of ; (semi-colon)

docker run image /bin/bash -c "cd /some/path && python a.py"
espadacoder11
In order to run multiple commands in docker, use /bin/bash -c with a semicolon ;

docker run image /bin/bash -c "cd /some/path; python a.py"

In this case the second command (python) will be executed only if the first command (cd) returns no error or an exit status. To avoid this use && instead of ; (semi-colon)

docker run image /bin/bash -c "cd /some/path && python a.py"
espadacoder11
In order to run multiple commands in docker, use /bin/bash -c with a semicolon ;

docker run image /bin/bash -c "cd /some/path; python a.py"

In this case the second command (python) will be executed only if the first command (cd) returns no error or an exit status. To avoid this use && instead of ; (semi-colon)

docker run image /bin/bash -c "cd /some/path && python a.py"

Login / Signup to Answer the Question.