Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deploy to elasticbeanstalk via CLI deploy command with Dockerrun.aws.json

I am running an elasticbeanstalk application, with multiple environments. This particular application is hosting docker containers which host a webservice.

To upload and deploy a new version of the application to one of the environments, I can go through the web client and click on "Upload and Deploy" and from the file option I select my latest Dockerrun.aws.json file, which references the latest version of the container that is privately hosted. The upload and deploy works fine and without issue.

To make it simpler for myself and others to deploy I'd like to be able to use the CLI to upload and deploy the Dockerrun.aws.json file. If I use the cli eb deploy command without any special configuration the normal process of zipping up the whole application and sending it to the host occurs and fails (it cannot reason out that it only needs to read the Dockerrun.aws.json file).

I found a documentation tidbit about controlling what is uploaded using the .elasticbeanstalk/config.yml file.

Using this syntax:

deploy: artifact: Dockerrun.aws.json

The file is uploaded and actually deploys successfully to the first batch of instances, and then always fails to deploy to the second set of instances.

The failure error is of the flavor: 'container exited unexpectedly...'

Can anyone explain, or provide link to the canonical approach for using the CLI to deploy single docker container applications?

like image 953
Courtland Caldwell Avatar asked Nov 20 '15 18:11

Courtland Caldwell


People also ask

How do I deploy in Elastic Beanstalk?

On the environment overview page, choose Upload and deploy. Choose Choose file, and then upload the sample application source bundle that you downloaded. The console automatically fills in the Version label with a new unique label.

What is Dockerrun AWS JSON?

A Dockerrun. aws. json file is an Elastic Beanstalk–specific JSON file that describes how to deploy a set of Docker containers as an Elastic Beanstalk application. You can use a Dockerrun. aws.


1 Answers

So it turns out that the method I listed about with the config.yml was correct. The reason I was seeing a partially successful deployment was because the previously running docker container on the hosts was not being stopped by EB.

I think that what was happening was that EB is sending something like

sudo docker kill --signal=SIGTERM $CONTAINER_ID instead of the more common sudo docker stop $CONTAINER_ID

The specific container I was running didn't respond to SIGTERM and so it would just sit there. When I tested it locally with SIGKILL it would (obviously) stop properly, but SIGTERM alone wouldn't stop it.

The issue wasn't the deployment methodology but rather confusion in the output that EB generated and my misinterpretation.

like image 168
Courtland Caldwell Avatar answered Oct 21 '22 12:10

Courtland Caldwell