The one thing you can't avoid when using GCP is the Google Could SDK. However, I don't want to install a tool on the local machine's system globals if possible.
So I decided to use google/cloud-sdk, the official Google Docker image, in my local environment.
Prepare Docker Images
There are three types of tags for google/cloud-sdk:
VERSION: Large image with additional components pre-installed, Debian-based.
VERSION-slim: Smaller image with no components pre-installed, Debian-based.
VERSION-alpine: Smallest image with no additional components installed, Alpine-based.
I wanted to use Google AppEngine & AppEngine components is included in the default components, so I decided to use
docker pull google/cloud-sdk:alpine docker run -it --rm google/cloud-sdk:alpine gcloud version # Google Cloud SDK 229.0.0 # bq 2.0.39 # core 2019.01.04 # gsutil 4.35
--name option to persist auth information:
docker run -it --name gcloud-config \ google/cloud-sdk:alpine gcloud auth login
Copy and paste the displayed URL into the browser and follow the instructions, and finally copy and paste the verification code displayed on the screen into the terminal.
--volumes-from gcloud-config to mount the volume containing the auth information:
docker run --rm --volumes-from gcloud-config \ google/cloud-sdk:alpine gcloud config list