Windows
To pass in Google Application Default Credentials to a container using Docker for Windows:docker run --rm -it -v "$env:appdata/gcloud\:/.config/gcloud" google/cloud-sdk
This demonstrates using the gsutil from the sdk and then a simple gsutil I put together for this blog that uses the Go library for Google Storage. It uses the Application Default Credentials.
You will need to change `/.config/gcloud` to be `/root/.config/gcloud`, `/home/myuser/.config/gcloud/` or whatever $HOME is for the user in the container you are running. For google/cloud-sdk, $HOME was set to /.
Linux
To pass in Google Application Default Credentials to a container on Linux:docker run --rm -it -v ~/.config/gcloud:/.config/gcloud google/cloud-sdk
Google Cloud Shell
The Google Cloud Shell can be very useful for development tasks too. Since it is a Google hosted VM, the credentials come from the network and not from files. You can pass those credential along to a docker container like so:docker run --rm -it --net host -e DEVSHELL_CLIENT_PORT=$DEVSHELL_CLIENT_PORT google/cloud-sdk
The `DEVSHELL_CLIENT_PORT` environment variable is only need by the SDK and not by my Go app.
My gsutil Test App
As mentioned before, I put together a simple `gsutil` test app in Go. Here is the gist:
Loading gist ...