将环境变量从 docker 传递给 supervisord
Pass environment variable from docker to supervisord
我用 docker 运行:
传递了两个环境变量
docker run -d --name foobar -e STAGE=testing -e STAGE_URL=http://...
和 dockersupervisor 启动几个进程的文件启动:
CMD ["/usr/bin/supervisord", "--configuration", "/etc/supervisor/conf.d/supervisord.conf"]
在 supervisord.conf
我尝试读取变量:
[program:build]
priority=1
autorestart=false
directory=/app/foobar
command=grunt build --force --stage ${STAGE} --stage-url ${STAGE_URL}
我也试过
$STAGE
和
%(STAGE)s
但 STAGE 从未被视为变量。它永远不会被实际内容取代。相反,它被视为一个简单的字符串。这导致:
--stage STAGE --stage-url STAGE_URL
而不是
--stage testing --stage-url http://...
这甚至可能是我正在做的吗?主管文档不清楚这个话题。有什么想法吗?
尝试%(ENV_STAGE)s
。
docs 似乎暗示这是要走的路。
我用 docker 运行:
传递了两个环境变量docker run -d --name foobar -e STAGE=testing -e STAGE_URL=http://...
和 dockersupervisor 启动几个进程的文件启动:
CMD ["/usr/bin/supervisord", "--configuration", "/etc/supervisor/conf.d/supervisord.conf"]
在 supervisord.conf
我尝试读取变量:
[program:build]
priority=1
autorestart=false
directory=/app/foobar
command=grunt build --force --stage ${STAGE} --stage-url ${STAGE_URL}
我也试过
$STAGE
和
%(STAGE)s
但 STAGE 从未被视为变量。它永远不会被实际内容取代。相反,它被视为一个简单的字符串。这导致:
--stage STAGE --stage-url STAGE_URL
而不是
--stage testing --stage-url http://...
这甚至可能是我正在做的吗?主管文档不清楚这个话题。有什么想法吗?
尝试%(ENV_STAGE)s
。
docs 似乎暗示这是要走的路。