gpt4 book ai didi

amazon-web-services - 使用 awsvpc 网络模式的 Docker 链接

转载 作者:行者123 更新时间:2023-12-02 18:48:04 25 4
gpt4 key购买 nike

我使用 tomcat:8.5-jre8-alpine 镜像在 ECS 中部署了一个 Java webapp。此任务的网络模式为 awsvpc;我有许多这样的任务在由 ALB 前置的 3 个 EC2 实例上运行。

这工作正常,但现在我想在每个 tomcat 容器前添加一个 nginx 反向代理,类似于此示例:https://github.com/awslabs/ecs-nginx-reverse-proxy/tree/master/reverse-proxy .

我的缩写容器定义文件是:

{
"containerDefinitions": [
{
"name": "nginx",
"image": "<NGINX reverse proxy image URL>",
"memory": "256",
"cpu": "256",
"essential": true,
"portMappings": [
{
"containerPort": "80",
"protocol": "tcp"
}
],
"links": [
"app"
]
},
{
"name": "app",
"image": "<app image URL>",
"memory": "1024",
"cpu": "1024",
"essential": true
}
],
"volumes": [],
"networkMode": "awsvpc",
"placementConstraints": [],
"family": "application-stack"
}

当我尝试保存新的任务定义时收到错误:“当网络类型为 awsvpc 时不支持链接”

我正在使用 awsvpc 网络模式,因为它使我可以通过安全组对入站流量进行精细控制。

使用 awsvpc 网络模式时,有没有办法用 2 个链接的容器创建任务定义?

最佳答案

您根本不需要链接部分,因为 awsvpc 允许您通过使用简单地引用其他容器

localhost:8080 (or whatever port is your other container mapped to)



在你的 nginx 配置文件中。

因此,从您的 json 中删除链接并在 nginx 配置中使用 localhost:{container-port}。就那么简单。

关于amazon-web-services - 使用 awsvpc 网络模式的 Docker 链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54772120/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com