在弹性Beanstalk中暴露Docker的多个端口 [英] Exposing multiple ports from Docker within Elastic Beanstalk
问题描述
我想使用Docker该容器因为它允许我在同一容器内运行多个互连的服务器进程,其中一些需要多个端口(例如RTSP)。这种应用程序有什么解决方法,其中RTSP和HTTP服务器都可以在EB上的同一Docker容器中运行?
您可以为Elastic Beanstalk的LoadBalancer / ReversProxy编写一个启动配置文件,以将其他端口转发到其EC2实例。 Ben Delarre 的示例:
资源:{
AWSEBLoadBalancerSecurityGroup:{
Type:AWS :: EC2 :: SecurityGroup,
属性:{
GroupDescription:启用80入站和8080出站,
VpcId:vpc-un1que1d,
SecurityGroupIngress:[{
IpProtocol:tcp,
FromPort:80,
ToPort:80,
CidrIp:0.0.0.0/0
$]
SecurityGroupEgress:[{
IpProtocol:tcp,
FromPort:8080,
ToPort:8080
CidrIp:0.0.0.0/0
}]
}
},
AWSEBLoadBalancer:{
Type: AWS :: ElasticLoadBalancing :: LoadBalancer,
属性:{
子网:[subnet-un1que1d2],
侦听器:[{
LoadBalancerPort :80,
InstancePort:8080,
协议:HTTP
}]
}
}
}
参考:
- 自定义AWS EB的ENV http://docs.aws.amazon .com / elasticbeanstalk / latest / dg / environment-resources.html
- http://docs.aws.amazon.com/ElasticLoadBalancing/latest/DeveloperGuide/using-elb-listenerconfig-quickref.html
From reading the AWS documentation, it appears that when using Docker as the platform on Elastic Beanstalk (EB) (as opposed to Tomcat, etc.), only a single port can be exposed. I'm trying to understand why Amazon created this restriction -- seems that you now can't even serve both HTTP and HTTPS.
I'd like to use Docker as the container since it allows me to run several interconnected server processes within the same container, some of which require multiple ports (e.g. RTSP). Are there any workarounds for this kind of application, where say an RTSP and HTTP server can both be running within the same Docker container on EB?
You could write an on-start config file for Elastic Beanstalk's LoadBalancer/ReversProxy to forward the additional ports to its EC2 instance(s). an example from Ben Delarre :
"Resources" : {
"AWSEBLoadBalancerSecurityGroup": {
"Type" : "AWS::EC2::SecurityGroup",
"Properties" : {
"GroupDescription" : "Enable 80 inbound and 8080 outbound",
"VpcId": "vpc-un1que1d",
"SecurityGroupIngress" : [ {
"IpProtocol" : "tcp",
"FromPort" : "80",
"ToPort" : "80",
"CidrIp" : "0.0.0.0/0"
}],
"SecurityGroupEgress": [ {
"IpProtocol" : "tcp",
"FromPort" : "8080",
"ToPort" : "8080",
"CidrIp" : "0.0.0.0/0"
} ]
}
},
"AWSEBLoadBalancer" : {
"Type" : "AWS::ElasticLoadBalancing::LoadBalancer",
"Properties" : {
"Subnets": ["subnet-un1que1d2"],
"Listeners" : [ {
"LoadBalancerPort" : "80",
"InstancePort" : "8080",
"Protocol" : "HTTP"
} ]
}
}
}
Ref:
- Customizing AWS EB's ENV http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/environment-resources.html
- http://docs.aws.amazon.com/ElasticLoadBalancing/latest/DeveloperGuide/using-elb-listenerconfig-quickref.html
这篇关于在弹性Beanstalk中暴露Docker的多个端口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!