ElasticBeanstalk MultiContainer docker with nginx
我有两个应用程序处理不同但相关的function。 我想将它们作为单个实体部署在单个主机端口上。
我的计划是使用elasticbeanstalk的多容器docker平台。 每个应用程序将是一个容器。
我怎么把他们绑在一起? 是否有可能在eb主机上安装和configurationnginx?
您需要在Dockerrun.aws.json
定义构成您的应用程序的所有容器(连同nginx容器)。
{ "AWSEBDockerrunVersion": 2, "volumes": [ { "name": "nginx-proxy-conf", "host": { "sourcePath": "/var/app/current/conf.d" } } ], "containerDefinitions": [ { "name": "first-app", "image": "FIRST_APP_IMAGE_NAME:FIRST_APP_TAG", "environment": [], "essential": true, "memoryReservation": 200, "mountPoints": [], "portMappings": [ { "hostPort": 8081, "containerPort": 8080 } ] }, { "name": "secondapp", "image": "SECOND_APP_IMAGE_NAME:SECOND_APP_TAG", "environment": [], "essential": true, "memoryReservation": 200, "mountPoints": [], "portMappings": [ { "hostPort": 8082, "containerPort": 8080 } ] } { "name": "nginx-proxy", "image": "nginx", "essential": true, "memoryReservation": 128, "portMappings": [ { "hostPort": 80, "containerPort": 80 } ], "links": [ "firstapp", "secondapp" ], "mountPoints": [ { "sourceVolume": "nginx-proxy-conf", "containerPath": "/etc/nginx/conf.d", "readOnly": true } ] } ] }
现在,当我们将应用程序容器链接到nginx容器时,我们可以使用它们的名称作为主机名来引用它们。
然后,您需要将使用nginxconfigurationconf.d/default.conf
文件(放在conf.d
文件夹中)的Dockerrun.aws.json压缩到您需要指定的位置
location /firstapp/ { proxy_pass http://firstapp; } location /secondapp/ { proxy_pass http://secondapp; }
在php应用程序之前请参考nginx代理的AWS例子。 http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_docker_v2config.html
- 在Docker中访问Elastic Beanstalk环境属性
- 在EBS中,从Dockerrun.aws.json -AWS中增加命令超时
- Nginx,AWS,EB,Docker,TCP Socketconfiguration400个不好的请求
- 具有多个环境的Elastic Beanstalk和它们之间的URL路由
- 何时在Elastic Beanstalk中使用多容器泊坞窗来运行Rails应用程序?
- 你如何在一个部署为弹性beanstalk工作的docker集装箱共享特权信息?
- 如何使用密码保护弹性beanstalk docker nginx中部署的django web应用程序
- 运行`eb local run`作为bash脚本的后台进程失败,出现各种错误(描述)
- 通过CLI部署命令与Dockerrun.aws.json部署到elasticbeanstalk