调试Elastic Beanstalk Docker运行失败?

时间:2015-05-20 19:42:15

标签: docker elastic-beanstalk

我是EB和AWS的新手,我的docker图像构建正常,但无法在Elastic Beanstalk上运行。我怀疑他们没有正确连接到数据库,但是,当我从命令行运行“eb logs”时,我没有得到任何有用的东西。以下是错误:

{
  "status": "FAILURE",
  "api_version": "1.0",
  "results": [
    {
      "status": "FAILURE",
      "msg": "(TRUNCATED)...rrun.aws.json: No such file or directory
        73927c49adff622a1a229d9369bdd80674d96d20f3eb99a9cdea786f4411a368
        Docker container quit unexpectedly after launch: Docker container quit unexpectedly on Wed May 20 17:15:02 UTC 2015:.
        Check snapshot logs for details.
        Hook /opt/elasticbeanstalk/hooks/appdeploy/pre/04run.sh failed.
        For more detail, check /var/log/eb-activity.log using console or EB CLI",
      "returncode": 1,
      "events": [
        {
          "msg": "Successfully pulled node:0.12.2-slim",
          "severity": "TRACE",
          "timestamp": 1432142064
        },
        {
          "msg": "Successfully built aws_beanstalk/staging-app",
          "severity": "TRACE",
          "timestamp": 1432142094
        },
        {
          "msg": "Docker container quit unexpectedly after launch: Docker container quit unexpectedly on Wed May 20 17:15:02 UTC 2015:. Check snapshot logs for details.",
          "severity": "ERROR",
          "timestamp": 1432142102
        }
      ]
    }
  ],
  "truncated": "true"
}

构建完成后:

[2015-05-20T17:15:02.694Z] INFO  [8603]  - [CMD-AppDeploy/AppDeployStage0/AppDeployPreHook/04run.sh] : Activity execution failed, because: cat: /var/app/current/Dockerrun.aws.json: No such file or directory
  cat: /var/app/current/Dockerrun.aws.json: No such file or directory
  73927c49adff622a1a229d9369bdd80674d96d20f3eb99a9cdea786f4411a368
  Docker container quit unexpectedly after launch: Docker container quit unexpectedly on Wed May 20 17:15:02 UTC 2015:. Check snapshot logs for details. (ElasticBeanstalk::ExternalInvocationError)
caused by: cat: /var/app/current/Dockerrun.aws.json: No such file or directory
  cat: /var/app/current/Dockerrun.aws.json: No such file or directory
  73927c49adff622a1a229d9369bdd80674d96d20f3eb99a9cdea786f4411a368
  Docker container quit unexpectedly after launch: Docker container quit unexpectedly on Wed May 20 17:15:02 UTC 2015:. Check snapshot logs for details. (Executor::NonZeroExitStatus)

docker容器在本地工作,那么我还能做些什么来弄清楚出了什么问题?我一直听说“快照日志”,但我在哪里查看这些快照日志?它们是我已经运行“eb logs”的输出吗?

3 个答案:

答案 0 :(得分:1)

我遇到了这个问题一两天。我设法通过转到 AWS Console > Elastic Beanstalk > Environment > ${YOUR_APPLICATION_ENV}

查看日志

在左侧窗格中;

日志 > 请求日志 > 下载 > 在任何文本编辑器中打开。

/var/log/eb-docker/containers/eb-current-app/

按照路径,您将看到导致错误的原因并可以修复它。

答案 1 :(得分:0)

当我的容器崩溃时,我遇到了这个问题,因为EBS和RDS之间不允许通信。如果您使用任何数据库,请尝试将其卷曲。另外,您可能想尝试sudo docker logs CONTAINER_ID尝试捕捉有用的东西。可能还有帮助的是尝试从实例手动启动容器。可能性很小。

答案 2 :(得分:0)

假设您具有运行容器的EC2实例的SSH访问权限,以下是一些日志文件,这些文件可用于调试Beanstalk中的单个容器Docker实例:

  • /tmp/docker_build.log
  • /tmp/docker_pull.log
  • /tmp/docker_run.log

为了查看正在运行的进程的错误日志,请先阅读 /tmp/docker_run.log 文件。该文件包含Docker进程ID。像这样:

c6ae58e4ad77e926f6a8230237acf95771c6b5d80d48fb1bc20591f964fd690c

前几个字符应与命令docker ps中列出的过程匹配。使用此值可在以下目录中找到相应的日志文件:

/ var / log / eb-docker / containers / eb-current-app /

文件名的格式为 eb- docker-ps-id -stdouterr.log