How to run multiple...
Notifications
Clear all

How to run multiple commands in docker at once

RSS

(@sathish)
Member Moderator
Joined: 1 year ago
Posts: 1391
10/05/2021 11:06 am

I'm trying to execute multiple commands like this.

码头工人运行图片cd /some/path && python a.py

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


Quote
(@ganesh)
Noble Member
Joined: 1 year ago
Posts: 1362
10/05/2021 11:07 am

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

码头工人运行图片/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)

码头工人运行图片/bin/bash -c "cd /some/path && python a.py"

ReplyQuote
Share:
Baidu