在Docker镜像上validationGoogle Cloud服务帐户
我在Docker镜像内部和外部发现了不同的行为,用于validationGoogle服务帐户。
外。 成功。
C:\Users\Ben\AppData\Local\Google\Cloud SDK>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]
运行docker容器,将.json密钥传递给tmp目录。
C:\Users\Ben\AppData\Local\Google\Cloud SDK>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
从docker中,确认文件在那里
root@4a4a9314f15c:/tmp# ls MeerkatReader-d77c0d6aa04f.json npm-24-b7aa1bcf npm-45-fd13ef7c npm-7-22ec336e
像以前一样运行相同的命令。 失败。
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.
什么可能导致这个错误? 更广泛地说,传递证书的build议策略是什么。 我已经试过这个,也失败了。 我正在使用cloudml API和云视觉,并且我希望在每次运行开始时避免使用手动gcloud init。
编辑:显示gcloud信息
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.
证实同样的行为
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.
你有没有试图从一开始就把图像放在图像上? 这是类似的结果吗?
另一方面,你有没有尝试过使用--key-file /tmp/MeerkatReader-d77c0d6aa04f.json
? 因为看起来你把json文件放在/tmp
。
您也可以考虑检查容器内部的networkingconfiguration,以及从外部检查docker。
这可能是由于docker虚拟机的时钟偏移造成的。 我debugging了google SDK的activate-service-account函数,得到如下错误信息:
There was a problem refreshing your current auth tokens: invalid_grant: Invalid JWT: Token must be a short-lived token and in a reasonable timeframe Please run: $ gcloud auth login to obtain new credentials, or if you have already logged in with a different account: $ gcloud config set account ACCOUNT to select an already authenticated account to use.
重启虚拟机之后,它就像一个魅力。