gpt4 book ai didi

docker-compose - 为 Cloudformation ECS + Fargate 部署添加环境变量

转载 作者:行者123 更新时间:2023-12-01 23:48:24 29 4
gpt4 key购买 nike

我们的镜像具有应该在 docker 运行期间定义的环境变量,知道如何将此变量添加到 cloudformation 文件中。我们目前有这样的东西:

Task:
Type: AWS::ECS::TaskDefinition
Properties:
Family: testenv
Cpu: 256
Memory: 512
NetworkMode:
RequiresCompatibilities:
- FARGATE
ExecutionRoleArn: !ImportValue ECSTaskExecutionRole
ContainerDefinitions:
- Name: bonalds
Image: gcr.io/zonalds-21/id-me:latest // image comes from gcr
Cpu: 256
Memory: 512
PortMappings:
- ContainerPort: 4567
Protocol: tcp
LogConfiguration:
LogDriver:
Options:
awslogs-group: 'zonalds'
awslogs-region: !Ref AWS::Region
awslogs-stream-prefix: 'routme'

我似乎在 AWS 文档中找不到任何信息,添加环境变量的最佳方法是什么?

最佳答案

您的容器定义可以保存环境变量。

ContainerDefinitions:
- Name: bonalds
Image: gcr.io/zonalds-21/id-me:latest // image comes from gcr
Cpu: 256
Environment:
- Name: Test
Value: 'test'
Memory: 512
PortMappings:
- ContainerPort: 4567
Protocol: tcp
LogConfiguration:
LogDriver:
Options:
awslogs-group: 'zonalds'
awslogs-region: !Ref AWS::Region
awslogs-stream-prefix: 'routme'

doc 中的更多信息

关于docker-compose - 为 Cloudformation ECS + Fargate 部署添加环境变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63829868/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com