In the task definition on ECS, I have provided Environment variable as following:
Key as HOST_NAME and Value as something.cloud.com
On my local I use this docker run command and I'm able to pass in my env variables, but through task definition the variables are not being passed to container.
The docker run command below works on local, but how do I set it up in the task definition in AWS ECS?
docker run -e HOST_NAME=something.cloud.com sid:latest
Environment variables are defined inside the container and some are passed in the task definition. So you can use describe-task-definition to see the extra variables.
Environment variables specified in the task definition are readable by all IAM users and roles that are allowed the DescribeTaskDefinition action for the task definition. Environment variable files are objects in Amazon S3 and all Amazon S3 security considerations apply. See the below section Required IAM permissions.
The family and container definitions are required in a task definition. In contrast, task role, network mode, volumes, task placement constraints, and launch type are optional. You can use these parameters in a JSON file to configure your task definition.
To set environment variablesSign in to the AWS Management Console and open the Amplify console . In the Amplify console, choose App Settings, and then choose Environment variables. In the Environment variables section, choose Manage variables. In the Manage variables section, under Variable, enter your key.
You should call it name
and not key
, see example below
{ "name": "nginx", "image": "", "portMappings": [ { "containerPort": 80, "hostPort": 80 } ], "environment": [ { "name": "HOST_NAME", "value": "something.cloud.com" } ] }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With