问题描述
我正在尝试使用docker-machine
在GCP上的VM实例上创建docker swarm节点。
docker-machine create swarm-node -d google --google-machine-type e2-standard-2 --google-zone europe-north1-a --google-project myproject-name
我在localhost docker-machine CLI中使用GCP服务帐户。
export GOOGLE_APPLICATION_CREDENTIALS="/home/my-name-here/.gcp/path-to-my-service-account-keyfile.json"
但是我得到了这个错误:
Error with pre-create check: "Project with ID \"myproject-name\" not found. googleapi: Error 403: Required 'compute.projects.get' permission for 'projects/myproject-name',forbidden"
如何向GCP服务帐户添加compute.projects.get
GCP IAM访问权限?
解决方法
最后我想通了,如以下解释: https://cloud.google.com/iam/docs/granting-changing-revoking-access
- 在Cloud Console中,转到IAM页面
- 点击添加。
- 输入服务帐户电子邮件地址(显示在服务帐户仪表板中)。
- 选择一个角色,在这种情况下为
Compute Admin
- 点击保存。
Etvoilà