title: Authenticate Google Cloud service account on docker image
body: <p>I'm finding different behavior from within and outside of a docker image for authenticating a google service account.</p>
  
  <p>Outside. Succeeds.</p>
  
  <pre><code>C:\Users\Ben\AppData\Local\Google\Cloud SDK&gt;gcloud auth activate-service-account 773889352370-compute@developer.gserviceaccount.com --key-file C:/Users/Ben/Dropbox/Google/MeerkatReader-d77c0d6aa04f.json --project api-project-773889352370
  Activated service account credentials for: [773889352370-compute@developer.gserviceaccount.com]
  </code></pre>
  
  <p>Run docker container, pass the .json key to tmp directory.</p>
  
  <pre><code>C:\Users\Ben\AppData\Local\Google\Cloud SDK&gt;docker run -it -v C:/Users/Ben/Dropbox/Google/MeerkatReader-d77c0d6aa04f.json:/tmp/MeerkatReader-d77c0d6aa04f.json  --rm -p "127.0.0.1:8080:8080" --entrypoint=/bin/bash  gcr.io/cloud-datalab/datalab:local-20161227
  </code></pre>
  
  <p>From within docker, confirm the file is there</p>
  
  <pre><code>root@4a4a9314f15c:/tmp# ls
  MeerkatReader-d77c0d6aa04f.json  npm-24-b7aa1bcf  npm-45-fd13ef7c  npm-7-22ec336e
  </code></pre>
  
  <p>Run the same command as before. Fails.</p>
  
  <pre><code>root@4a4a9314f15c:/tmp# gcloud auth activate-service-account 773889352370-compute@developer.gserviceaccoun
  t.com --key-file MeerkatReader-d77c0d6aa04f.json --project api-project-773889352370
  ERROR: (gcloud.auth.activate-service-account) Failed to activate the given service account. Please ensure provided key file is valid.
  </code></pre>
  
  <p>What might cause this error? More broadly, what is the <a href="https://github.com/GoogleCloudPlatform/cloud-sdk-docker" rel="noreferrer">suggested strategy</a> for passing credentials. I've tried this and it fails as well. I'm using the cloudml API and cloud vision, and i'd like to avoid manual gcloud init at the beginning of every run. </p>
  
  <p>EDIT: To show gcloud info</p>
  
  <pre><code>root@7ff49b26484f:/# gcloud info --run-diagnostics
  Network diagnostic detects and fixes local network connection issues.
  Checking network connection...done.
  Reachability Check passed.
  Network diagnostic (1/1 checks) passed.
  </code></pre>
  
  <p>confirmed same behavior</p>
  
  <pre><code>root@7ff49b26484f:/tmp# gcloud auth activate-service-account 773889352370-compute@developer.gserviceaccount.com --key-file MeerkatReader-d77c0d6aa04f.json --project api-project-773889352370
  ERROR: (gcloud.auth.activate-service-account) Failed to activate the given service account. Please ensure provided key file is valid.
  </code></pre>