我在Dockerfile中有以下bash脚本作为ENTRYPOINT
运行:
#!/bin/bash
python main.py
./bin/localstack start --host
当我启动该图像的容器时,我收到python命令的输出:
localstack | * Serving Flask app "main" (lazy loading)
localstack | * Environment: production
localstack | WARNING: Do not use the development server in a production environment.
localstack | Use a production WSGI server instead.
localstack | * Debug mode: on
localstack | * Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
localstack | * Restarting with stat
localstack | * Debugger is active!
localstack | * Debugger PIN: 177-561-621
但是我看不到localstack start命令的输出,也没有执行该命令。如果我将 shell 附加到容器上,并从工作目录中手动执行
./bin/localstack start --host
,则该命令将执行并显示输出。如何成功运行命令,并将输出重定向到已经作为python命令输出的同一shell?
最佳答案
我想到了。我只需要按以下方式链接两个过程:
#!/bin/bash
python main.py & ./bin/localstack start --host