smi*_*tan 3 amazon-web-services amazon-ecs docker
我使用 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 -代理。
我的缩写容器定义文件是:
{
"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"
}
Run Code Online (Sandbox Code Playgroud)
当我尝试保存新任务定义时收到错误:“当网络类型为 awsvpc 时不支持链接”
我正在使用 awsvpc 网络模式,因为它使我可以通过安全组对入站流量进行精细控制。
使用 awsvpc 网络模式时,有没有办法用 2 个链接的容器创建任务定义?
您根本不需要链接部分,因为 awsvpc 允许您通过使用简单地引用其他容器
localhost:8080(或其他容器映射到的任何端口)
在你的 nginx 配置文件中。
所以从你的 json 中删除链接并在 nginx 配置中使用 localhost:{container-port} 。就那么简单。
| 归档时间: |
|
| 查看次数: |
3952 次 |
| 最近记录: |