用EBS部署多容器docker环境(flask&nginx)

以下代码在使用docker-compose在本地运行时工作。 但是,当我将Flask和nginx容器推送到ECS并尝试从Elastic Beanstalk启动此应用程序时,如下所示引用Dockerrun.aws.json文件中的容器,我无法启动我的应用程序而没有错误。 有谁知道如何格式化Dockerrun.aws.json文件? 或者,问题在别处? 谢谢!

nginx / default.conf

server { listen 80; server_name example.org; charset utf-8; location /static { alias /usr/src/app/static; } location / { proxy_pass http://web:8000; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } } 

nginx / Dockerfile

 FROM nginx RUN mv /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf.old COPY default.conf /etc/nginx/conf.d/default.conf 

web / app.py

 from flask import Flask app = Flask(__name__) @app.route('/') def hello_world(): return 'Hello, World!' if __name__ == '__main__': app.run() 

web / Dockerfile

 FROM python:3.5-onbuild RUN apt-get update RUN apt-get -y install python3 RUN apt-get -y install python3-pip RUN apt-get -y install python3-dev RUN pip3 install flask 

Dockerrun.aws.json

 { "AWSEBDockerrunVersion": 2, "volumes": [ { "name": "UsrSrcAppStatic", "host": { "sourcePath": "/usr/src/app/static" } }, { "name": "WwwStatic", "host": { "sourcePath": "/www/static" } } ], "containerDefinitions": [ { "name": "web", "image": "############.dkr.ecr.us-east-1.amazonaws.com/app_web", "essential": true, "memory": 4096, "command": [ "/usr/local/bin/gunicorn", "-w", "2", "-b", ":8000", "app:app" ], "mountPoints": [ { "containerPath": "/usr/src/app/static", "sourceVolume": "UsrSrcAppStatic" } ] }, { "name": "nginx", "image": "############.dkr.ecr.us-east-1.amazonaws.com/app_nginx", "essential": true, "portMappings": [ { "hostPort": 80, "containerPort": 80 } ], "links": [ "web" ], "mountPoints": [ { "sourceVolume": "WwwStatic", "containerPath": "/www/static" } ], "memory": 128, "volumesFrom": [ { "sourceContainer": "web" } ] } ] } 

我也跟着AWS发布的nginx / php multicontainer 示例没有问题。

Interesting Posts