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

  • Node.js process, running in Docker container hangs without exiting or throwing when out of memory
  • Is it possible to pin the container to a remote machine instead of a new container instance?
  • Bunyan logger on aws leaks file descriptors
  • Simple Continuous Deliver procedure for docker in aws
  • Can I select which services to run with Atlassian's Localstack
  • Python/Django Elastic Beanstalk now failing on deploy
  • 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

  • ASP.NET Core - Issues while Debugging through Docker in Visual Studio 2015
  • Clone an image from a docker registry to another
  • Status 405 - docker - artifactory
  • Docker-compose Nginx php-fpm file not found
  • error while executing the following commands
  • Connecting to rabbitmq docker container from service in another container
  • 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.