问题描述
我正在尝试使用带有 Dockerrun.aws.json 的任务定义将我的 EFS 挂载到多 Docker 的 Elastic Beanstalk 环境。此外,我已将 EFS 的安全组配置为接受来自 EC2(EB 环境)安全组的 NFS 流量。
但是,我遇到了错误:
ECS 任务停止的原因是:来自守护进程的错误响应:创建 ecs-awseb-SeyahatciBlog-env-k3k5grsrma-2-wordpress-88eff0a5fc88f9ae7500: VolumeDriver.Create:挂载卷失败:挂载:未知文件系统 输入“efs”。
我正在使用 AWS 管理控制台上传这个 Dockerrun.aws.json 文件:
{
"AWSEBDockerrunVersion": 2,"authentication": {
"bucket": "seyahatci-docker","key": "index.docker.io/.dockercfg"
},"volumes": [
{
"name": "wordpress","efsVolumeConfiguration": {
"fileSystemId": "fs-d9689882","rootDirectory": "/blog-web-app/wordpress","transitEncryption": "ENABLED"
}
},{
"name": "mysql-data","rootDirectory": "/blog-db/mysql-data","transitEncryption": "ENABLED"
}
}
],"containerDefinitions": [
{
"name": "blog-web-app","image": "bireysel/seyehatci-blog-web-app","memory": 256,"essential": false,"portMappings": [
{"hostPort": 80,"containerPort": 80}
],"links": ["blog-db"],"mountPoints": [
{
"sourceVolume": "wordpress","containerPath": "/var/www/html"
}
]
},{
"name": "blog-db","image": "mysql:5.7","hostname": "blog-db","essential": true,"mountPoints": [
{
"sourceVolume": "mysql-data","containerPath": "/var/lib/mysql"
}
]
}
]
}
AWS 配置截图:
解决方法
在整个网络上搜索后,我没有遇到此问题的任何解决方案。我联系了 AWS Support。他们告诉我问题在于 Elastic Beanstalk 创建的 EC2 实例上缺少“amazon-efs-utils”扩展,然后我通过在 .ebextensions 文件夹中创建一个名为 efs.config 的文件来修复错误:
.ebextensions/efs.config
packages:
yum:
amazon-efs-utils: 1.2
最后,我在上传之前压缩了 .ebextensions 文件夹和我的 Dockerrun.aws.json 文件,问题已经解决。