简体   繁体   中英

How to update container image in AWS Fargate

我已将初始 docker 映像推送到存储库并使用该映像创建了 AWS Fargate,是否有任何方法可以更新映像,因为我的 docker 映像中有某些更改。

就这么简单:

aws ecs update-service --cluster <cluster> --service <service> --force-new-deployment

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

创建任务定义的新版本并使用最新标签更新容器并更新服务。

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 ie 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM