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