Jaideep Joshi
Jaideep Joshi

Reputation: 11

Error Docker deployment in Amazon Elastic Beanstalk - Docker container quit unexpectedly

I am trying deploy a simple docker container through Elastic Beanstalk but I am getting Docker container quit unexpectedly error. Not sure what is wrong here. Thanks in advance for the help.

Dockerrun.aws.json:

{
  "AWSEBDockerrunVersion": "1",
  "Image": {
    "Name": "janedoe/image",
    "Update": "true"
  },
  "Ports": [{
    "ContainerPort": "10010"
  }],
  "Volumes": [{
    "HostDirectory": "/home/ec2-user/testdocker",
    "ContainerDirectory": "/home/ec2-user/testdocker"
  }],
  "Logging": "/home/ec2-user/testlogs"
}

Dockerfile:

FROM centos:centos6
MAINTAINER janedoe

RUN echo "test" EXPOSE 10010

Log :

[2016-03-22T22:56:35.034Z] INFO  [15895] - [Application       update/AppDeployStage0/AppDeployPreHook/03build.sh] : Completed activity.     
Result:
  centos6: Pulling from library/centos
  Digest: sha256:ec1bf627545d77d05270b3bbd32a9acca713189c58bc118f21abd17ff2629e3f
  Status: Image is up to date for centos:centos6
  Successfully pulled centos:centos6
  Sending build context to Docker daemon 4.608 kB
  Sending build context to Docker daemon 4.608 kB

  Step 1 : FROM centos:centos6
   ---> ed452988fb6e
  Step 2 : MAINTAINER janedoe
   ---> Running in 8bce7dfb7e59
   ---> 04de6fffed04
  Removing intermediate container 8bce7dfb7e59
  Step 3 : RUN echo "test"
   ---> Running in 36cef1d7c0e5
  test
   ---> c5b3d119184c
  Removing intermediate container 36cef1d7c0e5
  Step 4 : EXPOSE 10010
   ---> Running in ea07cbcc1136
   ---> 45f9b3fe6503
  Removing intermediate container ea07cbcc1136
  Successfully built 45f9b3fe6503
  Successfully built aws_beanstalk/staging-app
[2016-03-22T22:56:35.034Z] INFO  [15895] - [Application update/AppDeployStage0/AppDeployPreHook] : Completed activity. Result:
  Successfully execute hooks in directory /opt/elasticbeanstalk/hooks/appdeploy/pre.
[2016-03-22T22:56:35.035Z] INFO  [15895] - [Application update/AppDeployStage0/EbExtensionPostBuild] : Starting activity...
[2016-03-22T22:56:35.550Z] INFO  [15895] - [Application update/AppDeployStage0/EbExtensionPostBuild/Infra-EmbeddedPostBuild] : Starting activity...
[2016-03-22T22:56:35.550Z] INFO  [15895] - [Application update/AppDeployStage0/EbExtensionPostBuild/Infra-EmbeddedPostBuild] : Completed activity.
[2016-03-22T22:56:35.587Z] INFO  [15895] - [Application update/AppDeployStage0/EbExtensionPostBuild] : Completed activity.
[2016-03-22T22:56:35.588Z] INFO  [15895] - [Application update/AppDeployStage0/InfraCleanEbextension] : Starting activity...
[2016-03-22T22:56:36.107Z] INFO  [15895] - [Application update/AppDeployStage0/InfraCleanEbextension] : Completed activity. Result:
  Cleaned ebextensions subdirectories from .
[2016-03-22T22:56:36.107Z] INFO  [15895] - [Application update/AppDeployStage0] : Completed activity. Result:
  Application update - Command CMD-AppDeploy stage 0 completed
[2016-03-22T22:56:36.107Z] INFO  [15895] - [Application update/AppDeployStage1] : Starting activity...
[2016-03-22T22:56:36.108Z] INFO  [15895] - [Application update/AppDeployStage1/AppDeployEnactHook] : Starting activity...
[2016-03-22T22:56:36.108Z] INFO  [15895] - [Application update/AppDeployStage1/AppDeployEnactHook/00run.sh] : Starting activity...
[2016-03-22T22:56:44.157Z] INFO  [15895] - [Application update/AppDeployStage1/AppDeployEnactHook/00run.sh] : Activity execution failed, because: 268f1a5e43874771bc6039977e9eb048e704c0b94a5e100a2a9ffbf2d9d7f271
  Docker container quit unexpectedly after launch: Docker container quit unexpectedly on Tue Mar 22 22:56:44 UTC 2016:. Check snapshot logs for details. (ElasticBeanstalk::ExternalInvocationError)
caused by: 268f1a5e43874771bc6039977e9eb048e704c0b94a5e100a2a9ffbf2d9d7f271
  Docker container quit unexpectedly after launch: Docker container quit unexpectedly on Tue Mar 22 22:56:44 UTC 2016:. Check snapshot logs for details. (Executor::NonZeroExitStatus)

Upvotes: 0

Views: 2360

Answers (2)

Nasaralla
Nasaralla

Reputation: 1839

It is easier to just see the command prompt output if your run it like

eb create <replace_with_your_env_name/> -vvv

Upvotes: 0

javierfdezg
javierfdezg

Reputation: 2107

You should use a CMD instead of a RUN on your Dockerfile.

When executing commands in a Dockerfile, you must choose carefully between RUN, CMD and ENTRYPOINT (extracted from the Docker reference):

  • RUN:

The RUN instruction will execute any commands in a new layer on top of the current image and commit the results. The resulting committed image will be used for the next step in the Dockerfile.

  • CMD:

The main purpose of a CMD is to provide defaults for an executing container. These defaults can include an executable, or they can omit the executable, in which case you must specify an ENTRYPOINT instruction as well.

  • ENTRYPOINT:

An ENTRYPOINT allows you to configure a container that will run as an executable.

You should have a deep read to the Docker reference and to the Docker best practices

Apart from that, if you intend to use the volumes you defined in your Dockerrun.aws.json, have in mind what is stated in the AWS documentation:

Do not specify the Image key in the Dockerrun.aws.json file when using a Dockerfile. .Elastic Beanstalk will always build and use the image described in the Dockerfile when one is present.

This means that your Dockerrun.aws.json will be ignored, so take care.

Upvotes: 2

Related Questions