我一生都无法弄清楚这一点。
我能找到的文档没有描述如何执行此操作(通过仪表板显示很多“Hello World”)。我通过命令行界面运行它。
我正在尝试弄清楚如何使用 AWS Batch 来处理一些数据。为此,我将工作流程容器化,并将 Docker 容器推送到 DockerHub。由于 Docker 容器只能看到容器内的文件,因此我在 Docker 容器中设置了目录来挂载卷。每个 Docker 容器都有以下目录:
/volumes/input/
、/volumes/output/
和 /volumes/database/
。我将必要的文件从 S3 复制到 EFS,但我无法让所有部分协同工作。
特别是,我需要帮助创建一个执行以下操作的作业定义:1)从 DockerHub 中提取我的 Docker 容器; 2)将EFS文件系统挂载到容器上; 3) 指定 EFS 中的本地路径以映射到我的容器中的卷。
这是我在运行 Docker 的本地计算机上的典型工作流程:
# Directories
LOCAL_WORKING_DIRECTORY=$(pwd)
LOCAL_WORKING_DIRECTORY=$(realpath -m ${LOCAL_WORKING_DIRECTORY})
LOCAL_OUTPUT_PARENT_DIRECTORY=../
LOCAL_OUTPUT_PARENT_DIRECTORY=$(realpath -m ${LOCAL_OUTPUT_PARENT_DIRECTORY})
LOCAL_DATABASE_DIRECTORY=${VEBA_DATABASE}
LOCAL_DATABASE_DIRECTORY=$(realpath -m ${LOCAL_DATABASE_DIRECTORY})
CONTAINER_INPUT_DIRECTORY=/volumes/input/
CONTAINER_OUTPUT_DIRECTORY=/volumes/output/
CONTAINER_DATABASE_DIRECTORY=/volumes/database/
# Parameters
ID=S1
R1=Fastq/${ID}_1.fastq.gz
R2=Fastq/${ID}_2.fastq.gz
NAME=VEBA-preprocess__${ID}
RELATIVE_OUTPUT_DIRECTORY=veba_output/preprocess/
# Command
CMD="preprocess.py -1 ${CONTAINER_INPUT_DIRECTORY}/${R1} -2 ${CONTAINER_INPUT_DIRECTORY}/${R2} -n ${ID} -p 16 -o ${CONTAINER_OUTPUT_DIRECTORY}/${RELATIVE_OUTPUT_DIRECTORY} -x ${CONTAINER_DATABASE_DIRECTORY}/Contamination/chm13v2.0/chm13v2.0"
# Docker
# Version
VERSION=1.2.0
# Image
DOCKER_IMAGE="jolespin/veba_preprocess:${VERSION}"
# Run
docker run \
--name ${NAME} \
--rm \
--volume ${LOCAL_WORKING_DIRECTORY}:${CONTAINER_INPUT_DIRECTORY}:ro \
--volume ${LOCAL_OUTPUT_PARENT_DIRECTORY}:${CONTAINER_OUTPUT_DIRECTORY}:rw \
--volume ${LOCAL_DATABASE_DIRECTORY}:${CONTAINER_DATABASE_DIRECTORY}:ro \
${DOCKER_IMAGE} \
-c "${CMD}"
我尝试通过 Fargate 使用 AWS Batch 执行此确切命令,但无法弄清楚作业定义。有人可以帮我实现这个目标吗?
{
"jobDefinitionName": "preprocess__35",
"type": "container",
"containerProperties": {
"image": "docker.io/jolespin/veba_preprocess:1.2.0",
"command": [
"preprocess.py",
"-1",
"/volumes/input/35_R1.fq.gz",
"-2",
"/volumes/input/35_R2.fq.gz",
"-n",
"35",
"-o",
"/volumes/output/veba_output/preprocess",
"-p",
"16"
],
"jobRoleArn": "arn:aws:iam::xxx:role/ecsTaskExecutionRole",
"executionRoleArn": "arn:aws:iam::xxx:role/ecsTaskExecutionRole",
"volumes": [
{
"name": "efs-volume-input",
"efsVolumeConfiguration": {
"fileSystemId": "fs-xxx",
"transitEncryption": "ENABLED",
"rootDirectory": "/mnt/efs/Fastq/"
}
},
{
"name": "efs-volume-output",
"efsVolumeConfiguration": {
"fileSystemId": "fs-xxx",
"transitEncryption": "ENABLED",
"rootDirectory": "/mnt/efs/veba_output"
}
}
],
"mountPoints": [
{
"sourceVolume": "efs-volume-input",
"containerPath": "/volumes/input",
"readOnly": true
},
{
"sourceVolume": "efs-volume-output",
"containerPath": "/volumes/output",
"readOnly": false
}
],
"environment": [],
"ulimits": [],
"resourceRequirements": [
{
"value": "16.0",
"type": "VCPU"
},
{
"value": "122880",
"type": "MEMORY"
}
],
"networkConfiguration": {
"assignPublicIp": "ENABLED"
},
"fargatePlatformConfiguration": {
"platformVersion": "LATEST"
},
"ephemeralStorage": {
"sizeInGiB": 40
}
},
"tags": {
"Name": "preprocess__35"
},
"platformCapabilities": [
"FARGATE"
]
}
如何指定挂载的 EFS 路径来映射到容器中的卷?
这些并不能解决我的问题:
这是我收到的错误(没有日志文件):
ResourceInitializationError: 无法调用 EFS utils 命令来设置 EFS 卷:stderr: b'mount.nfs4: 挂载 127.0.0.1:/mnt/efs/Fastq/ 失败,服务器给出的原因: 没有这样的文件或目录' : EFS utils 命令执行失败;代码:32
1) 当您使用 dockerhub 公共映像时,只需使用映像的名称并将您的作业放入一个安全组中,该安全组的出口规则允许访问互联网 (0.0.0.0/0):
"container": {
"image": "jolespin/veba_preprocess:1.2.0",
...
]
2 和 3)
当您想要使用 EFS 卷时,第一步是使用 volumes 属性定义卷,就像您已经做的那样。
"volumes": [
{
"name": "efs-volume",
"efsVolumeConfiguration": {
"fileSystemId": "fs-xxxxxxxxxx",
"rootDirectory": "/",
"transitEncryption": "DISABLED"
}
},
...
]
在此配置中,卷的 name 是 “efs-volume”,并且是我们用于将卷附加到容器的名称。 rootDirectory 是卷将使用的 efs 中的文件夹,在本例中为根 /。
第二步是定义 mountPoints,这是将前一个卷附加到容器的属性。
"mountPoints": [
{
"containerPath": "/internal/path1",
"readOnly": false,
"sourceVolume": "efs-volume"
},
...
]
上面的例子在容器“/internal/path1”中挂载了efs“/”
因此,由于volumes属性是一个数组,您可以根据需要使用不同的rootDirectory创建任意数量的卷,并使用mountPoints(具有不同的containerPath)将它们绑定到容器。
注意:
网络配置:
作业安全组必须在 2049 端口 (tcp) 中具有到 efs 安全组的出口规则
作业子网必须与 efs 具有挂载目标的位置相同...