amazon-web-services - AWS Elastic Beanstalk Docker 容器端口映射
问题描述
我有与 Elastic Beanstalk 多个 Docker-container-env 上的端口映射相关的问题。
我的 Dockerrun.aws.json 看起来像这样:
{
"AWSEBDockerrunVersion": 2,
"containerDefinitions": [
{
"name": "web",
"image": "exampleimage",
"hostname": "web",
"essential": true,
"memory": 128,
"portMappings": [
{
"hostPort": 3000,
"containerPort": 80
}
]
}
]
}
我的网络 dockerfile 看起来像这样:
FROM node:alpine as builder
WORKDIR '/app'
COPY ./package.json ./
RUN npm install
COPY . .
FROM nginx
EXPOSE 80
COPY --from=builder /app/build /usr/share/nginx/html
# at the end its a nginx images
这是否意味着我的 docker 容器在端口 80 上运行,而我在主机端口 3000 上运行?
如果在我的 AWS Elastic Beanstalk 上,端点就像
url-something-like-this-xxxx.com
如何访问容器?
url-something-like-this-xxxx:3000.com。??
太感谢了!
解决方案
访问协议指定的端口以外的其他端口的正确语法是://:示例
在端口 3000 上通过 http 访问网站
在端口 8443 上通过 https 访问网站
还要确保附加到您的实例或负载均衡器的安全组允许从您的 IP 地址或 0.0.0.0/0 访问端口 3000(如果您希望它是公共的)
链接到更新安全组的指南。
https://docs.aws.amazon.com/vpc/latest/userguide/VPC_SecurityGroups.html#AddRemoveRules
推荐阅读
- html - 动态生成的 SVG 不随容器调整大小
- nginx - 如果 www 已经在请求中,则排除重定向到 www 的条件 nginx 重写规则
- javascript - 在函数内抛出多个异常
- android - 启动画面加载程序动画没有动画
- http - nginx:我无法访问端口 80 上的默认虚拟主机。而是从错误的 server_name 获得响应
- python - 在文本分析中,分类器模型的*密度*是什么意思?
- php - LearnPress 4.x 版,如何移除钩子
- c - CS50 pset3 Check50 正在工作,但是当我测试我的代码时出现问题
- python - 将 django 从 3.0.4 升级到 3.2.6 导致测试时缺少 content_type 对象
- express - 使用nodejs express将gltf结果加载到404(未找到)的threejs