title: Deploying multicontainer docker environment (flask & nginx) with EBS
body: <p>The following code works when running locally with docker-compose.  However, when I push Flask and nginx containers to ECS and try to launch this application from Elastic Beanstalk, referencing the containers in my Dockerrun.aws.json file as shown below, I am unable to launch my application without error.  Does anyone know how the Dockerrun.aws.json file is to be formatted?  Or, does the problem lie elsewhere?  Thanks!</p>
  
  <p><strong>nginx/default.conf</strong>:</p>
  
  <pre><code>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;
      }
  }
  </code></pre>
  
  <p><strong>nginx/Dockerfile</strong>:</p>
  
  <pre><code>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
  </code></pre>
  
  <p><strong>web/app.py</strong>:</p>
  
  <pre><code>from flask import Flask
  
  
  app = Flask(__name__)
  
  @app.route('/')
  def hello_world():
      return 'Hello, World!'
  
  if __name__ == '__main__':
      app.run()
  </code></pre>
  
  <p><strong>web/Dockerfile</strong>:</p>
  
  <pre><code>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
  </code></pre>
  
  <p><strong>Dockerrun.aws.json</strong>:</p>
  
  <pre><code>{
      "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"
                  }
              ]
          }
      ]
  }
  </code></pre>
  
  <p>I have also followed the nginx/php multicontainer <a href="http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_docker_ecstutorial.html" rel="nofollow noreferrer">example</a> AWS has posted without issue.</p>