Docker – Using ebextensions with Docker in AWS Elasticbeanstalk

dockerelastic-beanstalk

As per documentation:

http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_docker_image.html

If you want to use ebextensions with a Single Container Docker Elasticbeanstalk environment, you have to:

  1. Use a zip archive as your application version
  2. Include a Dockerfile.aws.json file in the archive
  3. Include a Dockerfile file in the archive
  4. Include a .ebextensions folder in your archive

The Docker image used will be the image created by the Dockerfile, and not the image specified in Dockerfile.aws.json

In my case, I don't want Elasticbeanstalk to build my Docker image on the fly. Instead, I want to use an image from my AWS ECR.

In that case, can I just specify a Dockerfile that only includes:

FROM F11111111111.dkr.ecr.us-west-2.amazonaws.com/<my-image>:latest
EXPOSE 80

Will this just build a local non-modified image from the base and use that?

Best Answer

Have managed to test this and I can confirm that it does work.

Whereas ElasticBeanstalk assumes that your Dockerfile will build on and add to the base image, it is not actually necessary to do this.

The Dockerfile can simple refer to the base image your want to use (eg in the AWS ECR) and the port you want to expose when it is deployed to the ElasticBeankstalk instance.

This then allows you to use ebextensions in a Single Container Docker environment.

Related Topic