I have pushed the initial docker image into repository and created AWS Fargate using the image, is there any way to update the image as there are certain changes in my docker image.
4 Answers
As simple as:
aws ecs update-service --cluster <cluster> --service <service> --force-new-deployment

- 8,434
- 4
- 32
- 41
-
it will change IP and if Route 53 domain points to previous IP - it will stop work. should I put Load balancer as alias to prevent it? – Oleg Abrazhaev Jun 30 '21 at 17:52
See AWS documentation:
If you have updated the Docker image of your application, you can create a new task definition with that image and deploy it to your service.
Note
If your updated Docker image uses the same tag as what is in the existing task definition for your service (for example, my_image:latest), you do not need to create a new revision of your task definition. You can update the service using the procedure below, keep the current settings for your service, and select Force new deployment. The new tasks launched by the deployment pull the current image/tag combination from your repository when they start. The Force new deployment option is also used when updating a Fargate task to use a more current platform version when you specify LATEST. For example, if you specified LATEST and your running tasks are using the 1.0.0 platform version and you want them to relaunch using a newer platform version.
https://docs.aws.amazon.com/AmazonECS/latest/userguide/update-service.html#update-service

- 1
- 1

- 1,217
- 4
- 16
- 26
Create a new version of the task definition and update the container with latest labels and update the service.

- 727
- 3
- 8
- 21
You can write the configuration file once you created a cluster using the default-launch-type
as FARGATE for your application and define the respective parameters in your task definition i.e. ecs-params.yaml
Here is one file for the nginx:latest
image which is stored in Amazon ECR.
version: '2'
services:
web:
image: account-id.dkr.ecr.ap-southeast-1.amazonaws.com/nginx:latest
ports:
- "80:80"
logging:
driver: awslogs
options:
awslogs-group: awslogs-web
awslogs-region: ap-southeast-1
awslogs-stream-prefix: web-nginx
You simply change the image and you could get the updated image into your deployment as you update the service inside your cluster.
If you have updated the Docker image of your application, you can create a new task definition with that image and deploy it to your service. The service scheduler uses the minimum healthy percent and maximum percent parameters (in the service's deployment configuration) to determine the deployment strategy.
Note: The Execution Role
in task definition gives permissions to pull the images from container registry.
You could find the doc guide here, AWS ECS Update Service

- 5,002
- 1
- 28
- 36
-
As explained in the ECS Update Service doc, note that if your image & task definition use the same tag as before (e.g., latest), then you can just do an update of the ECS service and check the "Force new deployment" checkbox so that your new image gets deployed. – dSebastien Feb 14 '19 at 14:57