I try to start the cloud-datastore emulator inside docker with command below, seems I can't access it from the host machine
docker run -p 8000:8000 --name gcd google/cloud-sdk gcloud beta emulators datastore start --project=pi-docker --host-port 127.0.0.1:8000 --no-store-on-disk
the docker image can start without problem. , but when I try go access it from host machine, it get empty response,and our google datastore java client can't communicate with the docker instance via port 8000
curl localhost:8000
curl: (52) Empty reply from server
docker container log below.
Executing: /google-cloud-sdk/platform/cloud-datastore-emulator/cloud_datastore_emulator create --project_id=pi-docker /.config/gcloud/emulators/datastore
[datastore] Sep 20, 2016 4:22:23 AM com.google.cloud.datastore.emulator.CloudDatastore$CreateAction$1 apply
[datastore] INFO: Provided project_id to Cloud Datastore emulator create command, which is no longer necessary.
[datastore] Created new Cloud Datastore project in '/.config/gcloud/emulators/datastore'.
Executing: /google-cloud-sdk/platform/cloud-datastore-emulator/cloud_datastore_emulator start --host=127.0.0.1 --port=8000 --store_on_disk=False --consistency=0.9 --allow_remote_shutdown /.config/gcloud/emulators/datastore
[datastore] Sep 20, 2016 4:22:23 AM com.google.cloud.datastore.emulator.CloudDatastore$FakeDatastoreAction$7 apply
[datastore] INFO: Provided --allow_remote_shutdown to start command which is no longer necessary.
[datastore] Sep 20, 2016 4:22:23 AM com.google.cloud.datastore.emulator.impl.LocalDatastoreFileStub <init>
[datastore] INFO: Local Datastore initialized:
[datastore] Type: High Replication
[datastore] Storage: In-memory
[datastore] Sep 20, 2016 4:22:23 AM io.grpc.internal.ManagedChannelImpl <init>
[datastore] INFO: [ManagedChannelImpl@1409d7f5] Created with target 127.0.0.1:8000
[datastore] Sep 20, 2016 4:22:24 AM io.gapi.emulators.netty.NettyUtil applyJava7LongHostnameWorkaround
[datastore] INFO: Applied Java 7 long hostname workaround.
[datastore] API endpoint: http://127.0.0.1:8000
[datastore] If you are using a library that supports the DATASTORE_EMULATOR_HOST environment variable, run:
[datastore]
[datastore] export DATASTORE_EMULATOR_HOST=127.0.0.1:8000
[datastore]
[datastore] Dev App Server is now running.
[datastore]
docker exec -it gcd wget localhost:8000
converted 'http://localhost:8000' (ANSI_X3.4-1968) -> 'http://localhost:8000' (UTF-8)
--2016-09-20 04:48:16-- http://localhost:8000/
Resolving localhost (localhost)... ::1, 127.0.0.1
Connecting to localhost (localhost)|::1|:8000... failed: Connection refused.
Connecting to localhost (localhost)|127.0.0.1|:8000... connected.
HTTP request sent, awaiting response... 200 OK
Length: 3
Saving to: 'index.html'
index.html 100%[==============================================================================================>] 3 --.-KB/s in 0s
2016-09-20 04:48:16 (30.7 KB/s) - 'index.html' saved [3/3]