![](/img/trans.png)
[英]How do you do an ElasticBeanstalk deploy for multiple docker containers?
[英]How to connect multiple Docker containers in AWS ElasticBeanstalk?
我有一個打算在ElasticBeanstalk環境中運行的Docker多容器配置。
EB環境在公共子網中的VPC中運行,具有單個負載均衡器和單個實例綁定。
看起來所有容器都運行良好,但是即使我將它們定義為鏈接容器,它們也無法相互通信。
我需要怎么做才能使所有這些容器相互通信?
我的Dockerrun.aws.json看起來像這樣:
"containerDefinitions":
[
{
"name": "proxy",
"image": "nginx",
"essential": true,
"memory": 128,
"portMappings":
[
{
"hostPort": 80,
"containerPort": 80
}
],
"links":
[
"webapp"
],
"mountPoints":
[
{
"sourceVolume": "nginx-conf",
"containerPath": "/etc/nginx/conf.d",
"readOnly": true
},
{
"sourceVolume": "awseb-logs-proxy",
"containerPath": "/var/log/nginx"
}
]
},
{
"name": "webapp",
"image": "jetty",
"memory": 2048,
"essential": true,
"portMappings":
[
{
"hostPort": 8080,
"containerPort": 8080
}
],
"links":
[
"mongodb"
],
"mountPoints":
[
{
"sourceVolume": "jetty-webapp",
"containerPath": "/var/lib/jetty/webapps",
"readOnly": false
},
{
"sourceVolume": "awseb-logs-webapp",
"containerPath": "/var/log/jetty"
}
]
},
{
"name": "mongodb",
"image": "mongo",
"memory": 1024,
"essential": true,
"portMappings":
[
{
"hostPort": 27017,
"containerPort": 27017
}
],
"mountPoints":
[
{
"sourceVolume": "mongodb-data",
"containerPath": "/data/db",
"readOnly": false
}
]
}
]
就我而言,這與安全組無關,因為我公開公開的Nginx代理只有80個。
歸結為使用我在/ etc / host中的名稱(webapp,mongodb),而不是為容器創建的IP。
這修復了我從Nginx到Jetty以及從Jetty到MongoDB的連接。
在2017年,使用容器定義: links
到您要連接的Docker容器的名稱。 Docker的內置網橋將從那里建立連接。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.