Search code examples
phpjsonamazon-web-servicesamazon-ec2amazon-elastic-beanstalk

amazon elastic beanstalk eb local run with problems in my machine


ERROR: You can use "eb local" only with reconfigured, generic and multi container Docker platforms.

I want to create a multi container docker container web server on Amazon. I have already created an reconfigured - generic - multi container environment on amazon. I am trying to run this command to test my Dockerrun.aws.json file before deploy it but it is not working

I have already tested with amazon's example dockerrun but it didn't work

Dockerrun.aws.json

{
"AWSEBDockerrunVersion": 2,
"volumes": [
    {
        "name": "php-app",
        "host": {
            "sourcePath": "/var/app/current/php-app"
        }
    },
    {
        "name": "nginx-proxy-conf",
        "host": {
            "sourcePath": "/var/app/current/proxy/conf.d"
        }
    }
],
"containerDefinitions": [
    {
        "name": "php-app",
        "image": "php:fpm",
        "essential": true,
        "memory": 128,
        "mountPoints": [
            {
                "sourceVolume": "php-app",
                "containerPath": "/var/www/html",
                "readOnly": true
            }
        ]
    },
    {
        "name": "nginx-proxy",
        "image": "nginx",
        "essential": true,
        "memory": 128,
        "portMappings": [
            {
                "hostPort": 80,
                "containerPort": 80
            }
        ],
        "links": [
            "php-app"
        ],
        "mountPoints": [
            {
                "sourceVolume": "php-app",
                "containerPath": "/var/www/html",
                "readOnly": true
            },
            {
                "sourceVolume": "awseb-logs-nginx-proxy",
                "containerPath": "/var/log/nginx"
            },
            {
                "sourceVolume": "nginx-proxy-conf",
                "containerPath": "/etc/nginx/conf.d",
                "readOnly": true
            }
        ]
    }
]
}

Solution

  • There was a bug in EB CLI blocking use of default_platform: Multi-container Docker 17.03.1-ce (Generic) . You can find more here https://pypi.python.org/pypi/awsebcli/3.10.4 Update your EB CLI before go any further.

    What's more, if you created AWS beanstalk application in AWS Console (with browser) and then kinda imported it with eb init, there's a small change in .elasticbeanstalk/config.yml causing eb local run to fail with message

    ERROR: You can use "eb local" only with reconfigured, generic and multi container Docker platforms. 
    

    For instance, in my config.yml for imported application created with AWS Console, I've got

    default_platform: arn:aws:elasticbeanstalk:eu-west-1::platform/Multi-container Docker running on 64bit Amazon Linux/2.7.4
    

    Just change it to be

    default_platform: Multi-container Docker 17.03.1-ce (Generic)
    

    and you're ready to go!

    Tip: If there's a reason you don't want to update your EB CLI then use

    default_platform: Multi-container Docker 1.11.2 (Generic)