skip to Main Content

I am using ECS fargate.

When cheking force new depelopment it uses the container from ECR

However how ecs service choose the container????

As for Lambda, the tag XXXXXX:latest can be selected.

But there is not tag select in Task difinition either service setting of ECS.

How can I set this ?

ECS choose the latest tag or just choose the latest in ECR automatically?

3

Answers


  1. You define image URI in the task definition using following format

    • repository-url/image:tag
    • repository-url/image@digest

    If your image has a tag use the first format, and if you want to use a version without a tag use second format. Digest value is available in ECR repo.

    If you don’t specify any tag, by default latest tag would be used.

    Login or Signup to reply.
  2. ECR image and container are defined in the task definition. In ECS service, you choose the task definition and revision (ie. version of the task definition) that will be used.

    In task definition, you have image where you define ECR image and tag that will be used. If you don’t specify a tag, latest will be used by default:

    Something like:

    "containerDefinitions": [
      {
         "name": "my service",
         "image": "account-id.dkr.ecr.eu-central-1.amazonaws.com/ecr-repo-name:tag"
      }
    
    Login or Signup to reply.
  3. The ecs service depends on task definition which depends on container(s). So when forcing a new deployment from the ecs service, by default, the latest task definition is picked up. But in order to have a different container deployed, a new task definition will have to be created first with the desired container. In the task definition, the version tag can be specified in the image uri.

    But note that as of early July 2024, the tag will resolve to the image digest hash. So updating the image in ecr with the same tag, will require a task definition update to use the new image. As stated in the aws blog this is to "… ensures that the same container image is used throughout the lifecycle of the deployment, and increases both the security and consistency of your applications deployed as Amazon ECS services."

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search