[英]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:DefaultConnection
和EventBusSettings: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.