docker - 如何在docker中将参数传递给supervisord?

标签 docker supervisord

我正在 docker 中运行两个 python 服务。这两种服务都需要一个共同的参数,我在“docker run”期间提供了该参数

目前,我通过从 shell 脚本调用这两个服务来实现这一目标。但是,我认为正确的解决方案是在 docker 内部使用主管并通过它运行这两个服务。

我想要实现这样的目标:

[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 variable LOGLEVEL.

在您的情况下,您的公共(public)参数可以设置在使用 docker run -d -e "COMMON_ARG=myarg"传递给容器的环境变量中。

关于docker - 如何在docker中将参数传递给supervisord?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38844666/

相关文章:

django - celery 访问记录器文件 - [Errno 13] 权限被拒绝 :

ruby - 创建 puppet 包提供程序 - "No command service defined for provider"

php - 重启 Docker 容器之谜

mysql - Docker 无法连接到桥接口(interface)上的容器

django - Supervisord/Celery 输出日志

supervisord 未知错误使调度程序为 : ENOENT

docker - 定位给定图像的 Dockerfile

docker - 封装在uwsgi中,在Docker中运行的KafkaConsumer代码似乎无济于事

用于 _failed_ 构建的 docker hub webhook?

ubuntu - 主管 - 用户名无效