容器中 run > supervisor -> cron -f -m off 拿不到环境变量 怎么破

2022-09-22 10:59:19 +08:00
 dzdh

搜了很多资料说是 CMD 先 Printenv 到一个文件然后 cron 触发的 shell 中再 . /env

除了这样还有啥其他办法吗?

844 次点击
所在节点    Docker
4 条回复
mritd
2022-09-22 11:08:15 +08:00
直接 ENV 暴露 然后 CMD 通过 bash -c 执行 sup… 试试呢? 不过题外话,不太推荐容器里放守护工具然后启动多个应用
dzdh
2022-09-22 11:56:44 +08:00
还是 cmd run.sh printenv > /etc/environment 了
julyclyde
2022-09-22 12:23:30 +08:00
你是不是在 cron 里
第一行引用这个环境变量文件
第二行运行了实际干活的程序?
julyclyde
2022-09-22 12:26:37 +08:00
这事跟容器没多大关系
建议你看一下 man crond 里这句话
Cron supports access control with PAM if the system has PAM installed. For more information, see pam(8). A PAM configuration file for crond is installed in /etc/pam.d/crond. The daemon loads the PAM environment from the pam_env module. This can be over‐
ridden by defining specific settings in the appropriate crontab file.


man 5 crontab 里的环境变量方面的内容

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/882084

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX