Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set GOOGLE_APPLICATION_CREDENTIALS in Docker

I want to set GOOGLE_APPLICATION_CREDENTIALS inside my docker container using my key.json file but I don't want to copy this file into my container.

like image 689
katakuri Avatar asked Jul 22 '19 00:07

katakuri


2 Answers

 docker run \
   -e GOOGLE_APPLICATION_CREDENTIALS=/tmp/keys/[FILE_NAME].json \
   -v $GOOGLE_APPLICATION_CREDENTIALS:/tmp/keys/[FILE_NAME].json:ro \
   gcr.io/[PROJECT_ID]/[IMAGE]

Ref: https://cloud.google.com/run/docs/testing/local

like image 73
northtree Avatar answered Oct 19 '22 18:10

northtree


For anyone who is using a key file in the current working directory:

docker run \
  -e GOOGLE_APPLICATION_CREDENTIALS=/tmp/keys/[FILE_NAME].json \
  -v $(pwd):/tmp/keys/[FILE_NAME].json:ro \
  gcr.io/[PROJECT_ID]/[IMAGE]
like image 1
micmia Avatar answered Oct 19 '22 20:10

micmia