问题描述
我已经设法遵循 https://aws.amazon.com/blogs/compute/amazon-ecs-and-docker-volume-drivers-amazon-ebs/ 并使用 rex-ray Docker 卷插件在 ECS 上运行我的基于容器的服务。通过使用 docker exec -it <id> /bin/sh
主机 EC2 实例上是否有可以检查该数据的位置? rex-ray 卷是否安装在主机实例的任何位置?
我正在运行一个单节点 ECS 集群。我使用了以下任务定义。我在卷下的主机中声明了 sourcePath,但我在主机容器上没有看到任何 outputs 目录。
{
"ipcMode": null,"executionRoleArn": null,"containerDeFinitions": [
{
"dnsSearchDomains": null,"environmentFiles": null,"logConfiguration": {
"logDriver": "awslogs","secretoptions": null,"options": {
"awslogs-group": "/ecs/xxxxx","awslogs-region": "us-east-1","awslogs-stream-prefix": "ecs"
}
},"entryPoint": null,"portMappings": [],"command": null,"linuxParameters": null,"cpu": 0,"environment": [
{
"name": "save_path","value": "/outputs"
},{
"name": "watchdog_limit","value": "60"
},{
"name": "max_records_per_file","value": "14400"
}
],"resourceRequirements": null,"ulimits": null,"dnsServers": null,"mountPoints": [
{
"readOnly": null,"containerPath": "/outputs","sourceVolume": "rexray_volume"
}
],"workingDirectory": null,"secrets": null,"dockerSecurityOptions": null,"memory": null,"memoryReservation": 300,"volumesFrom": [],"stopTimeout": null,"image": "xxxxxxxxxxxxxxx.dkr.ecr.us-east-1.amazonaws.com/xxxxxxxxx:1.1","startTimeout": null,"firelensConfiguration": null,"dependsOn": null,"disableNetworking": null,"interactive": null,"healthCheck": null,"essential": true,"links": null,"hostname": null,"extraHosts": null,"pseudoTerminal": null,"user": null,"readonlyRootFilesystem": null,"dockerLabels": null,"systemControls": null,"privileged": null,"name": "datafeed"
}
],"taskRoleArn": null,"family": "Xxxxxxxx","pidMode": null,"requiresCompatibilities": [
"EC2"
],"networkMode": null,"cpu": null,"inferenceAccelerators": [],"proxyConfiguration": null,"volumes": [
{
"fsxWindowsFileServerVolumeConfiguration": null,"efsVolumeConfiguration": null,"name": "rexray_volume","host": {
"sourcePath": "/outputs"
},"dockerVolumeConfiguration": {
"autoprovision": true,"scope": "shared","driver": "rexray/ebs","driverOpts": {
"volumetype": "gp3","size": "20"
}
}
}
],"placementConstraints": [],"tags": []
}
解决方法
我设法访问了这些文件。设备已安装到 /var/lib/docker/plugins
文件夹内的路径。
这可以使用命令 lsblk
来识别。由于设备已经挂载,因此无法再次挂载到其他位置,但是,您可以创建一个 --bind 挂载到更方便的位置。
sudo mount --bind /var/lib/docker/plugins/xxxxxx/propagated-mount/volumes/rexray_vol outputs/
不过,我确实需要 su 才能访问文件。如果您有更好的解决方案,请告诉我。