如何向AWS ECS任务定义提供环境variables?

在ECS的任务定义中,我提供的环境variables如下:

键为HOST_NAME,价值为something.cloud.com

在我的本地我使用这个docker运行命令,我可以通过我的envvariables,但通过任务定义variables不被传递给容器。

这个docker run命令在本地工作,如何在AWS ECS的任务定义中进行设置:

docker运行-e HOST_NAME = something.cloud.com sid:最新

你应该叫它的name而不是key ,见下面的例子

  { "name": "nginx", "image": "", "portMappings": [ { "containerPort": 80, "hostPort": 80 } ], "environment": [ { "name": "HOST_NAME", "value": "something.cloud.com" } ] } 

您可以在任务定义JSON文件中设置主机名 var

 hostname Type: string Required: no The hostname to use for your container. This parameter maps to Hostname in the Create a container section of the Docker Remote API and the --hostname option to docker run.