我有一个按顺序运行多个Python脚本的应用程序。我可以在docker-compose中运行它们,如下所示:
command: >
bash -c "python -m module_a &&
python -m module_b &&
python -m module_c"
现在,我在Nomad中安排作业,并在Docker驱动程序的配置下添加了以下命令:
command = "/bin/bash"
args = ["-c", "python -m module_a", "&&","
"python -m module_b", "&&",
"python -m module_c"]
但Nomad似乎逃脱&&
,只运行第一个模块,并发出退出代码0.有没有办法运行类似于docker-compose的多线命令?
答案 0 :(得分:2)
以下内容可以保证与exec
驱动程序一起使用:
command = "/bin/bash"
args = [
"-c", ## next argument is a shell script
"for module; do python -m \"$module\" || exit; done", ## this is that script.
"_", ## passed as $0 to the script
"module_a", "module_b", "module_c" ## passed as $1, $2, and $3
]
请注意,只有一个参数作为脚本传递 - 紧跟在-c
之后的脚本。后续参数是该脚本的参数,而不是其他脚本或脚本片段。
更简单,你可以运行:
command = "/bin/bash"
args = ["-c", "python -m module_a && python -m module_b && python -m module_c" ]