我正在使用以下命令运行docker容器:
docker run -it -e CustomEnvVariable="val123" -p 80:80 imagename
该图片已运行supervisor以及我的应用的以下配置文件:
[program:myapp]
command=/usr/bin/dotnet /root/myapp/myapp.dll
directory=/root/myapp/
autostart=true
autorestart=true
stderr_logfile=/var/log/myapp.err.log
stdout_logfile=/var/log/myapp.out.log
environment=ASPNETCORE__ENVIRONMENT=Production
stopsignal=INT
user=root
主管启动后,如何从myapp中访问CustomEnvVariable
?
我在conf
文件environment
值中尝试了以下值:
environment=ASPNETCORE__ENVIRONMENT=Production,CustomEnvVariable=%(ENV_CustomEnvVariable)s
但重启主管时会收到此错误:
Restarting supervisor: Error:
Format string 'ASPNETCORE__ENVIRONMENT=Production,CustomEnvVariable="%(ENV_CustomEnvVariable)s"'
for 'environment' contains names which cannot be expanded
更多信息:
使用主管版本:3.0(通过apt-get install supervisor -y
安装)。
我通过检查CustomEnvVariable
的输出确认echo $CustomEnvVariable
的值已到达容器。
我快速扫描了应用程序可用的所有环境变量,结果如下:
{
"LC_ADDRESS": "",
"SUPERVISOR_PROCESS_NAME": "myapp",
"LC_MONETARY": "",
"LC_MESSAGES": "",
"LC_NAME": "",
"SUPERVISOR_ENABLED": "1",
"SUPERVISOR_SERVER_URL": "unix:///var/run/supervisor.sock",
"LC_COLLATE": "",
"ASPNETCORE__ENVIRONMENT": "Production",
"SUPERVISOR_GROUP_NAME": "myapp",
"LANG": "",
"LC_NUMERIC": "",
"LANGUAGE": "",
"LC_PAPER": "",
"LC_IDENTIFICATION": "",
"LC_CTYPE": "",
"LC_MEASUREMENT": "",
"TERM": "xterm",
"LC_TIME": "",
"LC_ALL": "",
"PATH": "/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin",
"LC_TELEPHONE": "",
"PWD": "/"
}