docker - 使用 ASP.NET Core 中的部分将 docker 机密读入配置
问题描述
我在 Docker 容器中运行 ASP.NET Core 应用程序。我需要将 docker 机密读入配置,但要包含部分。现在我在 Program.cs 中使用类似的东西
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
[...]
.ConfigureAppConfiguration((hostingContext, config) =>
{
config.AddKeyPerFile(directoryPath: "/run/secrets", optional: true);
})
[...]
它工作正常,但以平面结构存储记录Key:'Value'
。我想将它们存储在部分中,例如
Section: {
Key: 'Value'
}
能够为几个使用部分进行设置的包的 appsettings 提供值。
我怎样才能做到这一点?
解决方案
推荐阅读
- python-3.x - 在 matplotlib axes3d 中使用常量颜色
- android - 我正在使用具有一些内存错误的可过滤实现的回收器视图
- c# - OpenGL/SharpGL 中转换的简单代码(无矩阵理论课程)
- html - 如何使用 Roblox HttpService 连接到网络服务器?
- c# - 触摸按钮命令执行问题 | WPF | 虚拟机 | 视窗 10
- java - AbstractButton 类型中的方法 addActionListener(ActionListener) 不适用于参数
- bash - sed 删除一些但不是全部的双引号
- python - 使用 opencv VIdeoWriter 时出错
- token - 在 Powershell 中执行脚本时出现“ParserError: (:) [], ParentContainsErrorRecordException”
- c++ - 枚举(BETTER_ENUMS)和类型之间的 C++ 映射类型/功能