2

I have ESC service with EC2 task running on an EC2 instance. I am building and pushing docker image into ECR using GitHub Actions.

The ECS task has been updated with latest ECR image, but the problem is that the task has not been updated as latest source code.

When I pulled ECR latest docker image onto my local and run, it is working correctly with updated code. But, on ECS, it is not.

Anyone, please guide me why it has been happening and what is solution.

hsunny3993
  • 31
  • 5
  • It would help to see your task definition. You want to make sure your image tags are unique and that the task definition is updated with this unique tag otherwise you have to force a deployment. – jstewart379 Jul 09 '22 at 06:19
  • I shared my task definition. I already set ECS_IMAGE_PULL_BEHAVIOR=always in /etc/ecs/ecs.config on ECS cluster instance. – hsunny3993 Jul 09 '22 at 09:59
  • Just updating the ECR image isn't going to trigger an ECS service redeploy. You have to trigger an ECS deployment via some method, such as running the AWS CLI command `aws ecs update-service --force-new-deploy` after updating your ECR image. – Mark B Jul 09 '22 at 13:31
  • Yes, updating ECR image doesn't trigger upating ECS. I am using Github Actions[aws-actions/amazon-ecs-deploy-task-definition] to upload docker image and trigger ECS deployment. – hsunny3993 Jul 10 '22 at 05:31

1 Answers1

1

I resolved it. It was caused by that I mounted app root into EFS volume. So it was replacing an ECS container with old code on EFS volume, although ECS agent pull new docker image from ECR.

hsunny3993
  • 31
  • 5