Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use gsutil in startup-script on container-os image in GCP?

I'm creating my GCE instance with gcloud beta compute instances create-with-container and the following startup-script:

#! /bin/bash
gsutil cp gs://artifacts.<PROJECT-ID>.appspot.com/some-file .
docker-credential-gcr configure-docker
docker pull gcr.io/<PROJECT-ID>/image:tag
docker run --name compose --rm -v $PWD:$PWD -w $PWD -v /var/run/docker.sock:/var/run/docker.sock docker/compose:1.26.0 up -d --force-recreate

but I am ending with the following:

Jun 23 15:22:08 app startup-script[389]: INFO Found startup-script in metadata.
Jun 23 15:22:08 app startup-script[389]: INFO startup-script: /var/lib/google/startup-DqGmUt/tmpPyYsVd: line 2: gsutil: command not found
Jun 23 15:22:09 app startup-script[389]: INFO startup-script: ERROR: Unable to save docker config: mkdir /root/.docker: read-only file system

I tried installing gsutil also in the startup-script but it bails out with the same problem of /root being RO. Is it actually possible to do this on a COS image?

like image 514
warden Avatar asked Oct 23 '25 02:10

warden


1 Answers

For gcloud beta compute instances create with --create-disk=...image=projects/cos-cloud/global/images/cos-85-13310-1416-9,..., I used a containerized gsutil in the startup script:

#!/bin/bash
docker run -v /tmp:/tmp google/cloud-sdk:slim gsutil cp gs://BUCKET/file /tmp/
cat /tmp/file
like image 65
obk Avatar answered Oct 25 '25 17:10

obk