运行多容器 Docker 的 AWS BeanStalk 环境无法启动健康:严重
Posted
技术标签:
【中文标题】运行多容器 Docker 的 AWS BeanStalk 环境无法启动健康:严重【英文标题】:AWS BeanStalk environment running multi-container Docker fail to start with Health: Severe 【发布时间】:2016-04-23 22:12:06 【问题描述】:我正在尝试启动一个运行多容器 Docker 的 AWS BeanStalk 环境,但它失败并出现以下事件列表:
2016-01-18 16:58:57 UTC+0100 WARN Removed instance [i-a7162d2c] from your environment due to a EC2 health check failure.
2016-01-18 16:57:57 UTC+0100 WARN Environment health has transitioned from Degraded to Severe. None of the instances are sending data.
2016-01-18 16:47:58 UTC+0100 WARN Environment health has transitioned from Pending to Degraded. Command is executing on all instances. Command failed on all instances.
2016-01-18 16:43:58 UTC+0100 INFO Added instance [i-a7162d2c] to your environment.
2016-01-18 16:43:27 UTC+0100 INFO Waiting for EC2 instances to launch. This may take a few minutes.
2016-01-18 16:41:58 UTC+0100 INFO Environment health has transitioned to Pending. There are no instances.
2016-01-18 16:41:54 UTC+0100 INFO Created security group named: awseb-e-ih2exekpvz-stack-AWSEBSecurityGroup-M2O11DNNCJXW
2016-01-18 16:41:54 UTC+0100 INFO Created EIP: 52.48.132.172
2016-01-18 16:41:09 UTC+0100 INFO Using elasticbeanstalk-eu-west-1-936425941972 as Amazon S3 storage bucket for environment data.
2016-01-18 16:41:08 UTC+0100 INFO createEnvironment is starting.
健康状况标记为“严重”,我有以下日志:
98 % of CPU is in use.
Initialization failed at 2016-01-18T15:54:33Z with exit status 1 and error: Hook /opt/elasticbeanstalk/hooks/preinit/02ecs.sh failed.
. /opt/elasticbeanstalk/hooks/common.sh
/opt/elasticbeanstalk/bin/get-config container -k ecs_cluster
EB_CONFIG_ECS_CLUSTER=awseb-figure-test-ih2exekpvz
/opt/elasticbeanstalk/bin/get-config container -k ecs_region
EB_CONFIG_ECS_REGION=eu-west-1
/opt/elasticbeanstalk/bin/get-config container -k support_files_dir
EB_CONFIG_SUPPORT_FILES_DIR=/opt/elasticbeanstalk/containerfiles/support
is_baked ecs_agent
[[ -f /etc/elasticbeanstalk/baking_manifest/ecs_agent ]]
true
aws configure set default.output json
aws configure set default.region eu-west-1
echo ECS_CLUSTER=awseb-figure-test-ih2exekpvz
grep -q 'ecs start/'
initctl status ecs
initctl start ecs
ecs start/running, process 8418
TIMEOUT=120
jq -r .ContainerInstanceArn
curl http://localhost:51678/v1/metadata
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0curl: (7) Failed to connect to localhost port 51678: Connection refused
我的配置:
Environment type: Single Instance
Instance type: Medium
Root volume type: SSD
Root Volume Size: 8GB
Zone: EU-West
我的 Dockerrun.aws.json:
"AWSEBDockerrunVersion": "2",
"containerDefinitions": [
"essential": true,
"memory": 252,
"links": [
"redis"
],
"mountPoints": [
"containerPath": "/srv/express",
"sourceVolume": "_WebExpress"
,
"containerPath": "/srv/express/node_modules",
"sourceVolume": "SrvExpressNode_Modules"
],
"name": "web",
"image": "figure/web:latest",
"portMappings": [
"containerPort": 3000,
"hostPort": 3000
]
,
"essential": true,
"memory": 252,
"image": "redis",
"name": "redis",
"portMappings": [
"containerPort": 6379,
"hostPort": 6379
]
],
"family": "",
"volumes": [
"host":
"sourcePath": "./web/express"
,
"name": "_WebExpress"
,
"host":
"sourcePath": "/srv/express/node_modules"
,
"name": "SrvExpressNode_Modules"
]
【问题讨论】:
您是否在应用程序中设置了健康检查端点?:docs.aws.amazon.com/elasticbeanstalk/latest/dg/… 我没有。我刚刚意识到我没有按照文档docs.aws.amazon.com/elasticbeanstalk/latest/dg/… 中的描述配置角色和权限 【参考方案1】:@Kilinc:如果您使用多 docker 容器平台创建弹性 beanstalk 应用程序,则必须将以下策略列表添加到默认角色“aws-elasticbeanstalk-ec2-role”,或者您可以创建自己的角色。
-
AWSElasticBeanstalkWebTier
AWSElasticBeanstalkMulticontainerDocker
AWSElasticBeanstalkWorkerTier
谢谢
【讨论】:
【参考方案2】:我似乎忘记按照 AWS BeanStalk 文档中的说明设置策略和权限: http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_docker_ecstutorial.html
【讨论】:
你能解释一下你必须做什么才能让它工作吗?以上是关于运行多容器 Docker 的 AWS BeanStalk 环境无法启动健康:严重的主要内容,如果未能解决你的问题,请参考以下文章
如何在 Elasticbeanstalk 环境中运行的 docker 容器中承担 AWS 角色?
如果我只使用没有 hostPort 的 containerPort,AWS eb 的 docker 设置将不起作用。(多容器 Docker)
如果我只使用没有hostPort的containerPort,则AWS eb的docker设置不起作用。(多容器Docker)