Giter Club home page Giter Club logo

Comments (4)

ckeeney avatar ckeeney commented on May 30, 2024

I would guess that your issue is that you are binding the emulator to --host-port 127.0.0.1:8000. If you bind to the loopback interface of the container, you won't be able to reach the service from outside the container. I didn't see a way to tell the datastore emulator to bind to all interfaces, but a rather simple solution is to just tell docker which hostname to assign and bind to the hostname:

Note the -h gdatastore arg, as well as --host-port gdatastore:8000

 $docker run -h gdatastore -p 8000:8000 google/cloud-sdk gcloud beta emulators datastore start --project=pi-docker --host-port gdatastore:8000 --no-store-on-disk
Executing: /google-cloud-sdk/platform/gcd/gcd.sh create --project_id=pi-docker /.config/gcloud/emulators/datastore
[datastore] Created new Cloud Datastore project in '/.config/gcloud/emulators/datastore' with project ID 'pi-docker'.
Executing: /google-cloud-sdk/platform/gcd/gcd.sh start --host=gdatastore --port=8000 --store_on_disk=False --consistency=0.9 --allow_remote_shutdown /.config/gcloud/emulators/datastore
[datastore] API endpoint: http://localhost:8000/datastore
[datastore] If you are using a library that supports the DATASTORE_LOCAL_HOST environment variable, run:
[datastore] 
[datastore]   export DATASTORE_LOCAL_HOST=localhost:8000
[datastore] 
[datastore] Invoking dev_appserver with args: [--disable_update_check --jvm_flag=-Doauth.is_admin=true --property=datastore.index_configuration_format=yaml --port=8000 --address=gdatastore --property=datastore.force_is_high_replication=true --property=datastore.default_high_rep_job_policy_unapplied_job_pct=10.0 --property=datastore.no_storage=true --allow_remote_shutdown /.config/gcloud/emulators/datastore].
[datastore] Executing [/usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java, -Doauth.is_admin=true, -javaagent:/google-cloud-sdk/platform/gcd/.appengine/lib/agent/appengine-agent.jar, -Xbootclasspath/p:/google-cloud-sdk/platform/gcd/.appengine/lib/override/appengine-dev-jdk-overrides.jar, -classpath, /google-cloud-sdk/platform/gcd/CloudDatastore.jar:/google-cloud-sdk/platform/gcd/.appengine/lib/impl/appengine-api.jar:/google-cloud-sdk/platform/gcd/.appengine/lib/appengine-tools-api.jar:/google-cloud-sdk/platform/gcd/.appengine/lib/impl/appengine-api-stubs.jar, com.google.appengine.tools.development.DevAppServerMain, --property=kickstart.user.dir=/, --disable_update_check, --property=datastore.index_configuration_format=yaml, --port=8000, --address=gdatastore, --property=datastore.force_is_high_replication=true, --property=datastore.default_high_rep_job_policy_unapplied_job_pct=10.0, --property=datastore.no_storage=true, --allow_remote_shutdown, /.config/gcloud/emulators/datastore]
[datastore] Sep 21, 2016 4:20:28 AM java.util.prefs.FileSystemPreferences$1 run
[datastore] INFO: Created user preferences directory.
[datastore] Sep 21, 2016 4:20:28 AM com.google.apphosting.utils.jetty.JettyLogger info
[datastore] INFO: Logging to JettyLogger(null) via com.google.apphosting.utils.jetty.JettyLogger
[datastore] Sep 21, 2016 4:20:29 AM com.google.apphosting.utils.jetty.JettyLogger info
[datastore] INFO: jetty-6.1.x
[datastore] Sep 21, 2016 4:20:29 AM com.google.apphosting.utils.jetty.JettyLogger info
[datastore] INFO: Started SelectChannelConnector@gdatastore:8000
[datastore] Sep 21, 2016 4:20:29 AM com.google.appengine.tools.development.AbstractModule startup
[datastore] INFO: Module instance default is running at http://gdatastore:8000/
[datastore] Sep 21, 2016 4:20:29 AM com.google.appengine.tools.development.AbstractModule startup
[datastore] INFO: The admin console is running at http://gdatastore:8000/_ah/admin
[datastore] Sep 21, 2016 4:20:29 AM com.google.appengine.tools.development.DevAppServerImpl doStart
[datastore] INFO: Dev App Server is now running

And now, from my host machine:

$ curl localhost:8000
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <title>Cloud Datastore service</title>
  </head>

  <body>
    <h1>Cloud Datastore service</h1>
    <p><a href="https://developers.google.com/datastore/">Google Cloud Datastore</a> is a fully managed, schemaless database for storing non-relational data.</p>
    <p>If you were not expecting to see this page, check out the <a href="https://developers.google.com/datastore/docs/activate#limitations">activation guide</a> for more information.</p>
  </body>
</html>

from cloud-sdk-docker.

email2liyang avatar email2liyang commented on May 30, 2024

@ckeeney , thanks, that works!

from cloud-sdk-docker.

email2liyang avatar email2liyang commented on May 30, 2024

I have build my google datastore docker image with code below

and make sure I use docker -h gdatastore to start this docker image, then our test can access google datastore emulator inside docker container.

FROM google/cloud-sdk
MAINTAINER ivan.li

# Expose the default port
EXPOSE 8000

CMD ["gcloud","beta", "emulators", "datastore", "start","--project=pi-docker","--host-port", "gdatastore:8000","--consistency","1.0","--no-store-on-disk"]

from cloud-sdk-docker.

ckeeney avatar ckeeney commented on May 30, 2024

@email2liyang This is what I had in mind when I initially set out to use this. https://github.com/ckeeney/docker-datastore-integration

from cloud-sdk-docker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.