It’s a persistent disk (pd-50) and is based off of gcr.io/google.com/cloudsdktool/google-cloud-cli:alpine , but configured to run as non-root.
The problem is easy to reproduce with any docker image that doesn’t run on root. For example, this random image of docker image from dockerhub: frjaraur/non-root-nginx
To reproduce with the above image, POST something like this to Batch (you might need to edit the serviceAccount):
{
"allocationPolicy": {
"instances": [
{
"policy": {
"disks": [
{
"deviceName": "mySSD",
"newDisk": {
"sizeGb": "50",
"type": "pd-ssd"
}
}
],
"machineType": "e2-standard-2"
}
}
],
"labels": {
"batch-job-id": "redacted"
},
"location": {
"allowedLocations": [
"regions/us-central1",
"zones/us-central1-a",
"zones/us-central1-b",
"zones/us-central1-c",
"zones/us-central1-f"
]
},
"serviceAccount": {
"email": "redacted"
}
},
"logsPolicy": {
"destination": "CLOUD_LOGGING"
},
"taskGroups": [
{
"parallelism": "1",
"taskCount": "1",
"taskSpec": {
"computeResource": {
"cpuMilli": "2000",
"memoryMib": "2000"
},
"maxRetryCount": 5,
"maxRunDuration": "3600s",
"runnables": [
{
"container": {
"imageUri": "frjaraur/non-root-nginx",
"entrypoint": "/bin/sh",
"commands": [
"-c",
"echo Hello world! This is task ${BATCH_TASK_INDEX}. This job has a total of ${BATCH_TASK_COUNT} tasks. >/mnt/disks/mySSD/out.txt"
]
}
}
],
"volumes": [
{
"deviceName": "mySSD",
"mountPath": "/mnt/disks/mySSD",
"mountOptions": "rw,async"
}
]
}
}
]
}
I could modify our docker image to run as root, but this doesn’t seem like a great solution. I was hoping there was another way to control the permission of the destination mount. The documentation is not clear on the available mount options – as the man page for mount indicates the options differ depending on the type of system being mounted. I don’t know what a persistent disk would be – is it NFS? If so, that’s a problem because NFS doesn’t have an option to set the uid and gid.
This might be confusing things, but I’d actually also be OK with using a local ssd instead of a persistent disk, but I can’t get that to work at all. It immediately fails with no error message (i.e. if i change pd-ssd above to local-ssd, and 50 to 375)