how to provide environment variables to AWS ECS task definition?

In the task definition on ECS, I have provided Environment variable as following:

Key as HOST_NAME and Value as

  • Creating and running docker containers cluster with Kubernetes on AWS
  • What is the minimum healthy percent and maximum percent in Amazon ECS
  • port number not accessible when running webpack-dev-server
  • haproxy in docker container
  • Secure distribution of private keys to Docker on CoreOS
  • When docker run, an error occurs. “ValueError: Unable to configure handler 'watchtower': You must specify a region.”
  • on my local I use this docker run command and I ma able to pass in my env variables, but through task definition the variables are not being passed to container.

    This docker run command that works on local how to set it up in task definition in AWS ECS:

    docker run -e sid:latest

  • Auto setup a docker Image with ci runner
  • Docker restart entrypoint
  • How does one remove an image in Docker?
  • Could not access a running Docker Image of War (with tomcat) in minishift - OpenShift-Origin
  • ERROR: (gcloud.preview) Invalid choice: 'docker'. Did you mean 'dm-v2'?
  • SSH to Docker: Permission denied (publickey)
  • 2 Solutions collect form web for “how to provide environment variables to AWS ECS task definition?”

    You should call it name and not key, see example below

      "name": "nginx",
      "image": "",
      "portMappings": [
          "containerPort": 80,
          "hostPort": 80
      "environment": [
          "name": "HOST_NAME",
          "value": ""

    You can set hostname var at task definition JSON file

    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.
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.