- Docker on Amazon Web Services
- Justin Menga
- 277字
- 2025-02-17 05:10:17
Joining an ECS cluster
As the ECS create cluster wizard launched instances and created our ECS cluster, you may have wondered how exactly an ECS container instance joins an ECS cluster. The answer to this is very simple and can be understood easily by clicking on the EC2 instance ID link of the ECS container instance in your newly created cluster.
This link will take you to the EC2 Dashboard with the EC2 instance associated with the container instance selected, as shown in the following screenshot. Note that I have highlighted a number of elements that I will refer back to as we discuss ECS container instances:

If you right-click the instance and select Instance Settings | View/Change User Data (see the previous screenshot), you will be presented with the user data for the instance, which is a script that is run on instance creation and can be used to help initialize your EC2 instances:

The user data script that was configured by the getting started wizard is shown in the previous screenshot, which, as you can see, is a very simple bash script that writes the ECS_CLUSTER=test-cluster text to a file called /etc/ecs/ecs.config. In this example, recall that test-cluster is the name you configured for your ECS cluster, so this single configuration line in the referenced ECS agent configuration file simply tells the agent running on the ECS container instance to attempt to register with an ECS cluster called test-cluster.