Docker – AWS Elastic Beanstalk Docker Multicontainer Deployment Error, Can’t Set Memory

amazon-web-servicesdockerelastic-beanstalk

I'm transitioning one of my AWS Elastic Beanstalk applications over to Docker using Elastic Beanstalk's Multi-container Docker configuration. I've created a new EB Application with a new environment. When I attempt to deploy my Dockerrun.aws.json config, EB eventually fails with the following error in the events tab:

Service:AmazonECS, Code:ClientException, Message:Invalid setting for 
container 'api'. At least one of 'memory' or 'memoryReservation' must 
be specified., Class:com.amazonaws.services.ecs.model.ClientException

My Dockerrun.aws.json config is roughly as follows:

{
    "AWSEBDockerrunVersion": 2,
    "containerDefinitions": [
        {
            "name": "api_proxy",
            "image": "{account_id}.dkr.ecr.us-east-1.amazonaws.com/{repo}:latest",
            "essential": true,
            "memory": 128,
            "portMappings": [
                {
                    "hostPort": 80,
                    "containerPort": 80
                }
            ],
            "links": [
                "api"
            ]
        },
        {
            "name": "api",
            "image": "{account_id}.dkr.ecr.us-east-1.amazonaws.com/{repo}:latest",
            "environment": {
                "DJANGO_SETTINGS_MODULE": "api.aws"
            },
            "essential": true,
            "memory": 128
        }
    ]
}

Any help would definitely be appreciated.

Update 2018-02-15:

My current deployment process is as follows. I first create the Docker images and upload them to Amazon's ECR. I then zip the Dockerrun.aws.json file. Since this is the first deployment of the app in a new AWS EB environment, I'm currently uploading the zip file in the environment creation process. The platform I'm choosing is Preconfigured platform: Multi-container Docker. For Application Code, I upload my zipfile containing the Dockerrun.aws.json file.

Best Answer

As far as I can see from off doc - environment option should be object array, so your json should looks like

{
    "AWSEBDockerrunVersion": 2,
    "containerDefinitions": [{
        "name": "api",
        "image": "nginx:latest",
        "essential": true,
        "memory": 128,
        "environment": [{
            "name": "DJANGO_SETTINGS_MODULE",
            "value": "api.aws"
        }]
    },{
        "name": "api_proxy",
        "image": "nginx:latest",
        "essential": true,
        "memory": 128,
        "links": ["api"],
        "portMappings": [{
            "hostPort": 80,
            "containerPort": 80
        }]
    }]
}

At least I was able to run environment with the json above

Related Topic