更新; 2020 年 1 月 17 日 - 预览 ECS/EFS 支持
2020 年 1 月 17 日 AWS announced an preview for ECS support for EFS。需要注意的是,这目前是一个预览版;请参阅configuration documentation 中有关这意味着什么的信息。
您可以简单地定义新的EFSVolumeConfiguration 对象,而不是定义卷及其所有连接参数。
"EFSVolumeConfiguration": {
"fileSystemId": "fs-xxxxxx",
"rootDirectory": "/mnt/volume/path"
}
原答案
截至 2018 年 8 月,借助 docker 卷支持,您现在可以mount NFS shares directly into an ECS container。
目前可用的文档没有详细说明如何通过 docker volume 将 EFS 与 ECS 一起使用,但这是可能的。
配置 docker 卷
首先,在您的任务配置中包含一个volumes 部分,类似于以下内容:
"volumes": [
{
"name": "efs",
"host": null,
"dockerVolumeConfiguration": {
"autoprovision": null,
"labels": null,
"scope": "task",
"driver": "local",
"driverOpts": {
"type": "nfs",
"device": ":/",
"o": "addr=<fs-id>.efs.us-east-1.amazonaws.com,nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport"
}
}
}
]
确保更新 o 选项中的 addr 参数以匹配 EFS 文件系统的 DNS 名称。
然后,将此卷包含在您的一个容器定义中的挂载中。有关语法的更多信息,请参阅Docker Volumes。
"containerDefinitions": [
{
"mountPoints": [
{
"sourceVolume": "efs",
"containerPath": "/path/to/mount_volume",
"readOnly": false
}
]
}
]
用于 NFS 连接的配置选项是 AWS 在撰写本文时为 Mounting EFS filesystems 推荐的配置选项。