【发布时间】:2021-08-30 07:19:30
【问题描述】:
我正在使用 AWS Beanstalk 将我的项目部署在“在 64 位 Amazon Linux 上运行的多容器 Docker”中
根据文档,这是我的 Dockerrun.aws.json
{
"AWSEBDockerrunVersion": 2,
"containerDefinitions": [
{
"name": "child",
"image": "nithinsgowda/child",
"essential": true,
"memory": 256,
"portMappings": [
{
"hostPort": 9000,
"containerPort": 9000
}
],
"links": [
"master"
]
},
{
"name": "master",
"image": "nithinsgowda/master",
"essential": true,
"memory": 512,
"portMappings": [
{
"hostPort": 80,
"containerPort": 8080
}
],
"links": [
"child"
]
}
]
}
我可以从公共互联网的 80 端口访问我的主容器
在我的主容器中,我要对子容器进行 API 调用 我尝试了以下选项: 他们都没有工作
fetch('http://child/api')
fetch('http://child:9000/api')
fetch('http://15.14.13.12:9000/api') //My public DNS for the beanstalk application (Example)
如果它在本地 docker-compose 环境中,'http://child/api' 工作得很好。但这不适用于 Beanstalk。
如何从我的主容器与子容器通信?
我什至尝试了bindIP属性并分配了本地IP并尝试使用本地IP访问它,它仍然不起作用
查看服务器日志时,环境执行了 docker ps 并且两个容器都已启动并运行,端口映射也显示正确。
【问题讨论】:
标签: amazon-web-services docker docker-compose amazon-elastic-beanstalk