Modifying the task definition

Now that we have successfully run a first task in our ECS cluster, it is time to modify the task definition to use our images of the pets application instead of the Nginx image. We will be using the image fundamentalsofdocker/ch14-web:1.0 in this task definition ,the source code of which can be found in our code repository in folder labs/ch14/ecs/web.

The steps to change the task definition are as follows:

  1. Select the pets-task-def task definition and then select revision 1.
  2. The Create new revision button will be enabled. Click it and in the appearing page scroll down to the Container Definitions section. There you should see our web container. Click it and modify the image and instead of nginx:alpine add the value fundamentalsofdocker/ch14-web:1.0.
  3. Click Update and then click Create. This will create a new revision 2 of our task definition called pets-task-def:2.
  4. Go back to the cluster and stop the current task. Then click Run new Task.
  5. In the dialog, fill in the same information that you did when running the first task but make sure that under Task Definition you select revision 2, namely pets-task-def:2.
  6. Click Run Task and wait until the task is provisioned and running. This may take a while since ECS needs to download the image from Docker Hub. Once the task is ready, navigate to its details and locate the public IP address assigned to it.

Use the browser to verify you can reach our web component. If all went well, we should see the following screenshot:

The pets web component is running in our ECS pets cluster

Now our web component is running but we also need the database from which it retrieves the nice cat images. So we need to create yet another revision of the task definition, which will include our db component.