简体   繁体   English

AWS ECS更新服务会擦除mongo容器

[英]AWS ECS Updating service wipes mongo container

I have a node/mongo app deployed using ECS. 我有一个使用ECS部署的节点/ mongo应用程序。 The running task contains two containers, one for my node api, and another for my mongo database. 正在运行的任务包含两个容器,一个用于我的节点api,另一个用于我的mongo数据库。 When I push changes I make to my api and create a new task revision + update my service using it, it deploys the changes, but wipes my database clean every time. 当我推送更改时,将对api进行更改并创建一个新的任务修订版+使用它来更新我的服务,它会部署更改,但每次都会清除数据库。

  1. With this setup, is updating a service always going to deploy a new mongo container? 通过此设置,更新服务是否总是要部署新的mongo容器?
  2. Any chance I could revert to the previous state of that service? 我是否有可能恢复到该服务的先前状态?
  3. Would it be better to create a separate task for each container 为每个容器创建一个单独的任务会更好吗

Any help would be greatly appreciated 任何帮助将不胜感激

  1. yes, it will always deploy a new container from the image that is mentioned in the task definition. 是的,它将始终根据任务定义中提到的映像部署新容器。

    When UpdateService stops a task during a deployment, the equivalent of docker stop is issued to the containers running in the task. 当UpdateService在部署期间停止任务时,等效docker stop会发布给任务中运行的容器。 This results in a SIGTERM and a 30-second timeout. 这将导致SIGTERM和30秒超时。

update-service 更新服务

  1. No, When service updated it automatically remove the old container and image. 否,服务更新后,它会自动删除旧的容器和图像。 because By default, the Amazon ECS container agent automatically cleans up stopped tasks and Docker images that are not being used by any tasks on your container instances. 因为默认情况下,Amazon ECS容器代理会自动清除容器实例上任何任务未使用的已停止任务和Docker映像。

You can control this behaviour using ECS_ENGINE_TASK_CLEANUP_WAIT_DURATION 您可以使用ECS_ENGINE_TASK_CLEANUP_WAIT_DURATION来控制此行为

This variable specifies the time to wait before removing any containers that belong to stopped tasks. 此变量指定删除属于已停止任务的任何容器之前要等待的时间。 The image cleanup process cannot delete an image as long as there is a container that references it. 图像清理过程无法删除图像,只要有一个引用它的容器即可。 After images are not referenced by any containers (either stopped or running), then the image becomes a candidate for cleanup. 在任何容器(停止或运行中​​)都未引用映像之后,该映像将成为清除对象。 By default, this parameter is set to 3 hours but you can reduce this period to as low as 1 minute, if you need to for your application. 默认情况下,此参数设置为3小时,但是如果需要,可以将这一时间减少到1分钟。

  1. Yes, It would be better to have a separate task definition. 是的,最好有一个单独的任务定义。 Also, I would recommend mounting in the DB container to avoid such losses in future. 另外,我建议将其安装在数据库容器中,以避免将来发生此类损失。

AWS ecs docker-volumes AWS ECS docker-卷

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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