简体   繁体   English

通过docker-compose文件修改环境json数组变量

[英]Modify environment json array variable via docker-compose file

I'm trying to modify environment variables of my application via docker-compose.yml file.我正在尝试通过docker-compose.yml文件修改我的应用程序的环境变量。

My appsettings.Development.json looks like below:我的appsettings.Development.json如下所示:

{
  "ConnectionStrings": {
    "DefaultConnection": "Server=127.0.0.1,1433;Database=app;User Id=sa;Password=P@ssw0rd"
  },
  "EventBusSettings": {
    "HostAddress": "amqp://guest:guest@localhost:5672"
  },
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft": "Warning",
      "Microsoft.Hosting.Lifetime": "Information"
    }
  },
  "Roles": [
    "Member",
    "Admin"
  ]
}

Using docker-compose.yml I modify ConnectionStrings:DefaultConnection and EventBusSettings:HostAddress like in example below:使用 docker-compose.yml 我修改ConnectionStrings:DefaultConnectionEventBusSettings:HostAddress如下例所示:

# ...
app:
    image: app
    container_name: app
    build:
      context: .
      dockerfile: Services/App/Dockerfile
    ports:
      - 5000:5000
    depends_on:
      - db
      - rabbitmq
      - portainer
    environment:
      - ConnectionStrings:DefaultConnection=Server=db,1433;Database=app;User Id=sa;Password=P@ssw0rd
      - EventBusSettings:HostAddress=amqp://guest:guest@rabbitmq:5672
# ...

How can I modify first element of Roles in appsettings.Development.json via docker-compose.yml?如何通过 docker-compose.yml 在appsettings.Development.json修改Roles第一个元素?

您可以通过将Roles__0设置为您想要的值来实现。

暂无
暂无

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

相关问题 docker 将环境变量写入IConfiguration,怎么办? - docker compose environment variable to IConfiguration, how to do? Docker:应用程序通过docker-compose工作正常,但是如何通过Visual Studio和调试运行它? - Docker: applications works fine via docker-compose up, but how to run it via Visual Studio and debug? .net核心应用程序无法连接到RabbitMQ(两者都通过docker-compose在docker网络中运行) - .net core app ca't connect to rabbitMQ (both running in a docker network via docker-compose) 如何解决 docker-compose 环境变量不起作用 ASP.Net Core MVC - How to solve docker-compose environment variables not working ASP.Net Core MVC 如何将“appsettings.json”中的值替换为通过 docker 环境变量传入的值 - How do I replace a value in "appsettings.json" with a value that I pass in via a docker environment variable 使用docker-compose运行docker image - Run docker image with docker-compose 如何在 docker-compose 命令中将 appsettings.json 值替换为 .env 变量以启动 ASP.NET 核心 MVC 应用程序? - How do I replace appsettings.json values with .env variable in docker-compose command to launch an ASP.NET Core MVC app? docker-compose 构建复制失败 - docker-compose build copy failed 如何将 IdentityServer 与 docker-compose 一起使用? - How to use IdentityServer with docker-compose? 在不同的docker-compose之间共享容器 - Share containers between different docker-compose
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM