默认情况下,Docker Compose CLI 部署到 ECS 上下文中的 Fargate。 This AWS blog post提到以下内容:
In general, the compute mapping is such that all ECS tasks are backed, by default, by AWS Fargate. However, there are scenarios that are not yet supported by Fargate that require the Compose CLI mapping to fall back to use EC2. For example, when you request GPU support for a container.
我的应用程序不需要 GPU 支持,但我仍然更愿意使用 EC2 而不是 Fargate,因为 Fargate 没有免费套餐(请参阅 this post on Serverfault )。似乎这个提议已经有一段时间了(首先是 April of 2020 ),但到目前为止还没有任何进展。
那么与此同时,有没有办法使用 Docker Compose CLI 部署到 EC2?
另外,如果这更适合不同的 stackexchange,请告诉我,我会移动它。
最佳答案
如果您必须坚持 docker compose integration with ECS ,您可以使用 docker compose Convert
并修改 Cloudformation 模板以使用 EC2
启动类型,但您必须使用 AWS CLI 手动上传此云模板(这不会首先使用 docker compose 非常有意义)。
如果您需要使用EC2
,我会推荐ecs-cli
。您可以create the cluster使用两种启动类型(FARGATE 或 EC2)之一,该命令还能够 place the containers described in a compose file在 ECS 上运行的底层 EC2 实例中。 (有一个很棒的教程吧here)
关于docker - 将 Docker Compose CLI 与 EC2 结合使用而不是 Fargate,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72181130/