Docker撰写嵌套环境变量 [英] Docker Compose Nested Environment Variable

查看:211
本文介绍了Docker撰写嵌套环境变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个现有的应用程序,该应用程序使用的应用程序配置文件如下所示:

I have an existing app that uses a app config file that looks like:

"ConnectionInfo": {
    "ServerName": "The Server URL",
    "DatabaseName": "The DatabaseName",
    "UserName": "The User Name",
    "Password": "The Password"}

现在,当我进行简单设置时,说

Now, when I have a simple setting, say

"ConnectionString":"My Connection String"

我了解如何在compose.yml文件中覆盖它:

I understand how to override it in the compose.yml file:

environment:
  - ConnectionString=what I want it to be

问题是,如何在顶部设置服务器名称?

The question is, how do you set, say, the server name in the top?

推荐答案

请使用双下划线(__)代替冒号(:).

Please use double underscore (__) as the following instead of a colon (:).

environment:
  - ConnectionInfo__ServerName=MyServerName

请参考

对于环境变量中指定的分层配置值,a 冒号(:)可能不适用于所有平台.双下划线(__)是 所有平台都支持.

For hierarchical config values specified in environment variables, a colon (:) may not work on all platforms. Double underscore (__) is supported by all platforms.

这篇关于Docker撰写嵌套环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆