用docker运行谷歌数据存储模拟器
我正在尝试与docker创build数据存储模拟器,并按照https://cloud.google.com/datastore/docs/tools/datastore-emulator
我还使用了云端SDK https://hub.docker.com/r/google/cloud-sdk/
我能够创build模拟器并进行身份validation,但是当我尝试访问它throght localhost:8000 / datastore它给了我“未find”的回应,
我怎样才能访问数据存储数据?
我用来创build它的命令是:
docker run -p 8000:8000 google/cloud-sdk gcloud beta emulators datastore start --project=pname --host-port localhost:8000 --no-store-on-disk
数据存储模拟器确实只支持HTTP/2
。 这意味着你应该使用支持客户端访问模拟器中的数据,例如google-cloud-python,google-cloud-java等。这个官方库支持使用环境variablesDATASTORE_EMULATOR_HOST
和DATASTORE_PROJECT_ID
设置模拟器主机。
样本设置variables
export DATASTORE_EMULATOR_HOST=localhost:8000 export DATASTORE_PROJECT_ID=project-id-in-google
这应该允许客户端访问模拟器,而不是完成上面的variables访问实时数据存储使用:
unset DATASTORE_EMULATOR_HOST unset DATASTORE_PROJECT_ID
笔记:
-
DATASTORE_EMULATOR_HOST
可以从正在运行的Docker容器中检索,如下所示[datastore] API endpoint: http://localhost:8000 [datastore] If you are using a library that supports the DATASTORE_EMULATOR_HOST environment variable, run: [datastore] [datastore] export DATASTORE_EMULATOR_HOST=localhost:8000 [datastore] [datastore] Dev App Server is now running.
-
DATASTORE_PROJECT_ID
应该与在线项目匹配
-
tid位
-
检查仿真器状态
GET
请求到http://localhost:8000
,如果仿真器正在运行,它应该返回ok
-
重置模拟器通过
POST
请求删除所有数据到http://localhost:8000/reset