目前,我通过调用shell脚本中的服务来实现此目的.但是,我认为正确的解决方案是在docker中使用supervisor并通过它运行两个服务.
我希望实现这样的目标:
[program:A] command=python -m A.py <argument> [program:B] command=python -m B.py <argument>
dockerfile如下所示:
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf CMD ["/usr/bin/supervisord"]
我如何将论证传递给主管?
您可以使用环境变量:从 supervisor doc开始Environment variables that are present in the environment at the time that
supervisord
is started can be used in the configuration file using the Python string expression syntax%(ENV_X)s
:
[program:example] command=/usr/bin/example --loglevel=%(ENV_LOGLEVEL)s
In the example above, the expression
%(ENV_LOGLEVEL)s
would be expanded to the value of the environment variableLOGLEVEL
.
在您的情况下,可以在传递给容器的环境变量中设置您的公共参数,其中docker run -d -e“COMMON_ARG = myarg”.
精彩评论