在AWS ECS中的任务定义之间链接容器? [英] Linking containers between task definitions in AWS ECS?

查看:354
本文介绍了在AWS ECS中的任务定义之间链接容器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在AWS ECS中设置一个具有关联数据库的基本Web应用程序。在本地,我将这些设置放在不同的容器中,而在ECS上,我想要有单独的任务定义,以便我可以分别缩放两个。

I'm trying to setup a basic web application, which has an associated database, in AWS ECS. Locally I have these setup in different containers, and on ECS, I'd like to have separate task definitions so that I may scale the two separately.


  1. 我在ECS中成功地将我的第一个任务定义注册为 david_mongodb 。它有一个名为 david_mongodb 的容器。

  2. 然后我尝试将我的第二个任务定义注册为 david_web ,它有一个名为 david_web 的容器,通过 david_mongodb:db 链接数据库。 / li>
  3. 当我点击创建时,会返回错误:

  1. I registered my first task definition as david_mongodb successfully in ECS. It has a container named david_mongodb in it.
  2. Then I attempted to register my second task definition as david_web, which has a container named david_web that links the database via david_mongodb:db.
  3. When I click 'Create', it returns an error:

Unable to create Task Definition
Linked container 'david_mongodb:db' doesn't exist.


似乎任务定义看不到其他任务定义中的容器名称?我想在同一个任务定义中同时使用 david_web david_mongodb 容器,但是我不想要做到这一点:这将阻止我分别扩展Web应用程序或数据库。 此概述似乎证实我的架构被推荐...

It seems like task definitions can't see container names in other task definitions? I'm thinking putting both david_web and david_mongodb containers in the same task definition would work, but I don't want to do that: it would prevent me from scaling either web app or database separately. This overview seems to confirm that my architecture is recommended...

那么如何链接生活在不同任务定义中的容器?或者还有另一个聪明的方法来处理这个问题?

So how do I link containers that live in different task definitions? Or is there another clever way of handling this?

推荐答案

ECS任务定义中的链接类似于 Docker链接,并且只有当容器是同一任务定义的一部分(作为单个任务定义的一部分的容器)时才起作用放在同一主机上)。为了在不同任务定义中的容器之间进行通信,您需要一种机制来发现容器位于何处(主机)以及通信端口。

Links in an ECS task definition are analogous to Docker links and only work when the containers are part of the same task definition (containers that are part of a single task definition are placed together on the same host). In order to communicate between containers in different task definitions, you'll need a mechanism for discovering where the containers are located (what host) as well as the port for communication.

ECS通过服务功能与ELB集成,其中任务将自动注册在ELB中,并在ELB中注册。如果您想避免ELB,另一种模式可能是大使容器(有一个称为 ecs-task-kite 使用ECS API),或者您可能对覆盖网络感兴趣(编织具有相当详细的< a href =http://weave.works/guides/service-discovery-with-weave-aws-ecs.html>入门指南解决方案)。

ECS has integration with ELB through the service feature, where tasks will be automatically registered in the ELB and deregistered in the ELB appropriately. If you want to avoid ELB, another pattern might be an ambassador container (there's a sample called the ecs-task-kite that uses the ECS API) or you might be interested in an overlay network (Weave has a fairly detailed getting started guide for their solution).

这篇关于在AWS ECS中的任务定义之间链接容器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆