Skip to Content

Mounting your local gcloud credentials in Docker

Posted on One min read

Many Google Cloud Platform products need credentials to work. During development, you often work on your local machine using the gcloud command-line interface (more info about the gcloud SDK).

You can issue a gcloud auth login command to log in and be authenticated. And a gcloud auth application-default to generate application default credentials.

If you are running your project using a Docker container, you can use local credentials with your container in a very straight forward way. You only need gcloud CLI installed on your Docker image or using the google/cloud-sdk image and using the following trick using docker run:

docker run -v ~/.config/gcloud:/root/.config/gcloud your_docker_image

The -v flag instructs Docker to mount the folder with your local machine credentials inside your Docker image.

comments powered by Disqus