Amazon Elastic Container Service
Developer Guide (API Version 2014-11-13)

Launching an Amazon ECS Container Instance

You can launch an Amazon ECS container instance using the AWS Management Console, as described in this topic. Before you begin, be sure that you've completed the steps in Setting Up with Amazon ECS. After you've launched your instance, you can use it to run tasks.

To launch a container instance

  1. Open the Amazon EC2 console at

  2. From the navigation bar, select the region to use.

  3. From the console dashboard, choose Launch Instance.

  4. On the Choose an Amazon Machine Image (AMI) page, choose Community AMIs.

  5. Choose an AMI for your container instance. You can choose the Amazon ECS-optimized AMI, or another operating system, such as CoreOS or Ubuntu. If you do not choose the Amazon ECS-optimized AMI, you must follow the procedures in Installing the Amazon ECS Container Agent.


    For more information about Amazon ECS-specific CoreOS installation instructions, see Running CoreOS Container Linux with AWS EC2 Container Service.

    To use the Amazon ECS-optimized AMI, type amazon-ecs-optimized in the Search community AMIs field and press the Enter key. Choose Select next to the amzn-ami-2018.03.g-amazon-ecs-optimized AMI.

    The current Amazon ECS–optimized AMI IDs by region are listed below for reference.

    Region AMI ID
    us-east-2 ami-09a64272e7fe706b6
    us-east-1 ami-0b9a214f40c38d5eb
    us-west-2 ami-00430184c7bb49914
    us-west-1 ami-0e7dd5fe55b87a5fe
    eu-west-2 ami-0209769f0c963e791
    eu-west-3 ami-06b685336aa497c15
    eu-west-1 ami-05b65c0f6a75c1c64
    eu-central-1 ami-0bb804e8cd910a664
    ap-northeast-2 ami-0d947b1901b27a37c
    ap-northeast-1 ami-08681de00a0aae54f
    ap-southeast-2 ami-05b48eda7f92aadbe
    ap-southeast-1 ami-0a3f70f0255af1d29
    ca-central-1 ami-00d1bdbd447b5933a
    ap-south-1 ami-0590d0dd683026eab
    sa-east-1 ami-01bca91ecf4c1f494
    us-gov-west-1 ami-5256cf33


    The current Amazon ECS-optimized AMI can be retrieved using the AWS CLI with the following command:

    aws ssm get-parameters --names /aws/service/ecs/optimized-ami/amazon-linux/recommended
  6. On the Choose an Instance Type page, you can select the hardware configuration of your instance. The t2.micro instance type is selected by default. The instance type that you select determines the resources available for your tasks to run on.

  7. Choose Next: Configure Instance Details.

  8. On the Configure Instance Details page, configure the following fields accordingly.

    1. Set the Number of instances field depending on how many container instances you want to add to your cluster.

    2. (Optional) To use Spot Instances, for Purchasing option, select the check box next to Request Spot Instances. You also need to set the other fields related to Spot Instances. For more information, see Spot Instance Requests.


      If you are using Spot Instances and see a Not available message, you may need to choose a different instance type.

    3. For Network, choose the VPC into which to launch your container instance.

    4. For Subnet, choose a subnet to use, or keep the default option to choose the default subnet in any Availability Zone.

    5. Set the Auto-assign Public IP field depending on whether you want your instance to be accessible from the public internet. If your instance should be accessible from the internet, verify that the Auto-assign Public IP field is set to Enable. If not, set this field to Disable.


      Container instances need external network access to communicate with the Amazon ECS service endpoint, so if your container instances do not have public IP addresses, then they must use network address translation (NAT) to provide this access. For more information, see NAT Gateways in the Amazon VPC User Guide and HTTP Proxy Configuration in this guide. For more information, see Tutorial: Creating a VPC with Public and Private Subnets for Your Clusters.

    6. Select the ecsInstanceRole IAM role value that you created for your container instances in Setting Up with Amazon ECS.


      If you do not launch your container instance with the proper IAM permissions, your Amazon ECS agent cannot connect to your cluster. For more information, see Amazon ECS Container Instance IAM Role.

    7. (Optional) Configure your Amazon ECS container instance with user data, such as the agent environment variables from Amazon ECS Container Agent Configuration. Amazon EC2 user data scripts are executed only one time, when the instance is first launched.

      By default, your container instance launches into your default cluster. To launch into a non-default cluster, choose the Advanced Details list. Then, paste the following script into the User data field, replacing your_cluster_name with the name of your cluster.

      #!/bin/bash echo ECS_CLUSTER=your_cluster_name >> /etc/ecs/ecs.config

      Or, if you have an ecs.config file in Amazon S3 and have enabled Amazon S3 read-only access to your container instance role, choose the Advanced Details list. Then, paste the following script into the User data field, replacing your_bucket_name with the name of your bucket to install the AWS CLI and write your configuration file at launch time.


      For more information about this configuration, see Storing Container Instance Configuration in Amazon S3.

      #!/bin/bash yum install -y aws-cli aws s3 cp s3://your_bucket_name/ecs.config /etc/ecs/ecs.config

      For more information, see Bootstrapping Container Instances with Amazon EC2 User Data.

  9. Choose Next: Add Storage.

  10. On the Add Storage page, configure the storage for your container instance.

    If you are using an Amazon ECS-optimized AMI before the 2015.09.d version, your instance has a single volume that is shared by the operating system and Docker.

    If you are using the 2015.09.d or later Amazon ECS-optimized AMI, your instance has two volumes configured. The Root volume is for the operating system's use, and the second Amazon EBS volume (attached to /dev/xvdcz) is for Docker's use.

    You can optionally increase or decrease the volume sizes for your instance to meet your application needs.

  11. Choose Review and Launch.

  12. On the Review Instance Launch page, under Security Groups, you see that the wizard created and selected a security group for you. Instead, select the security group that you created in Setting Up with Amazon ECS using the following steps:

    1. Choose Edit security groups.

    2. On the Configure Security Group page, select the Select an existing security group option.

    3. Select the security group you created for your container instance from the list of existing security groups, and choose Review and Launch.

  13. On the Review Instance Launch page, choose Launch.

  14. In the Select an existing key pair or create a new key pair dialog box, choose Choose an existing key pair, then select the key pair that you created when getting set up.

    When you are ready, select the acknowledgment field, and then choose Launch Instances.

  15. A confirmation page lets you know that your instance is launching. Choose View Instances to close the confirmation page and return to the console.

  16. On the Instances screen, you can view the status of your instance. It takes a short time for an instance to launch. When you launch an instance, its initial state is pending. After the instance starts, its state changes to running, and it receives a public DNS name. If the Public DNS column is hidden, choose Show/Hide, Public DNS.