简体   繁体   English

ASP.NET Docker UserSecrets 位置

[英]ASP.NET Docker UserSecrets location

I have created an ASP.NET application that connects to microsoft sql database and needs a password for that.我创建了一个 ASP.NET 应用程序,该应用程序连接到 microsoft sql 数据库并且需要密码。 When running the application under Windows it takes the password from secrets.json file located in C:\Users<user>\AppData\Roaming\Microsoft\UserSecrets<UserSecretsId>在 Windows 下运行应用程序时,它会从位于 C:\Users<user>\AppData\RoamingUserId>\Microsoft\UserSecrets 的 secrets.json 文件中获取密码

When running under Docker I am unable to find out where I should put the secrets.json file.在 Docker 下运行时,我无法找到应该将 secrets.json 文件放在哪里。 I tried /root/.microsoft/usersecrets/ as it seemed to work for others but no for me.我尝试了 /root/.microsoft/usersecrets/ 因为它似乎对其他人有用,但对我无效。 Guess I am not among the lucky ones.猜猜我不是幸运儿。

Does anyone have an idea?有人有想法吗?

Rather than using user secrets I would suggest you pass these values in as environmental variables.我建议您将这些值作为环境变量传递,而不是使用用户机密。 While it is possible to store user secrets inside a docker image, you'd be putting your secrets into a repository, which is not something you want to do.虽然可以将用户机密存储在 docker 映像中,但您会将机密放入存储库中,这不是您想要做的事情。 Instead, you can pass in the values as environmental variables when the docker run is performed.相反,您可以在执行 docker 运行时将值作为环境变量传递。 See Environmental Variable Configuration Provider请参阅环境变量配置提供程序

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM