python - How do I run a google appengine docker image on a compute engine instance? -


i have following docker file:

from gcr.io/google_appengine/python-compat maintainer me@me.com  run apt-get update run apt-get -y upgrade  add ./app/ /app add app.yaml /app/  run mkdir -p /var/log/app_engine 

i create log directory because otherwise following error

sudo docker run gcr.io/my-project/ae-image traceback (most recent call last):   file "/home/vmagent/python_vm_runtime/vmboot.py", line 133, in <module>     run_file(__file__, globals())   file "/home/vmagent/python_vm_runtime/vmboot.py", line 129, in run_file     execfile(_paths.script_file(script_name), globals_)   file "/home/vmagent/python_vm_runtime/google/appengine/tools/vmboot.py", line 32, in <module>     initialize.initializefilelogging()   file "/home/vmagent/python_vm_runtime/google/appengine/ext/vmruntime/initialize.py", line 92, in initializefilelogging     app_log_file, maxbytes=max_log_bytes, backupcount=log_backup_count)   file "/usr/lib/python2.7/logging/handlers.py", line 117, in __init__     baserotatinghandler.__init__(self, filename, mode, encoding, delay)   file "/usr/lib/python2.7/logging/handlers.py", line 64, in __init__     logging.filehandler.__init__(self, filename, mode, encoding, delay)   file "/usr/lib/python2.7/logging/__init__.py", line 901, in __init__     streamhandler.__init__(self, self._open())   file "/usr/lib/python2.7/logging/__init__.py", line 924, in _open     stream = open(self.basefilename, self.mode) ioerror: [errno 2] no such file or directory: '/var/log/app_engine/app.log.json' 

but following error:

sudo docker run -ti gcr.io/my-project/ae-image /app/app.yaml log 1 1433422040537094 using module_yaml_path argv: /app/app.yaml traceback (most recent call last):   file "/home/vmagent/python_vm_runtime/vmboot.py", line 133, in <module>     run_file(__file__, globals())   file "/home/vmagent/python_vm_runtime/vmboot.py", line 129, in run_file     execfile(_paths.script_file(script_name), globals_)   file "/home/vmagent/python_vm_runtime/google/appengine/tools/vmboot.py", line 65, in <module>     main()   file "/home/vmagent/python_vm_runtime/google/appengine/tools/vmboot.py", line 61, in main     vmservice.createandrunservice(module_yaml_path)   file "/home/vmagent/python_vm_runtime/google/appengine/ext/vmruntime/vmservice.py", line 154, in createandrunservice     service.createserver()   file "/home/vmagent/python_vm_runtime/google/appengine/ext/vmruntime/vmservice.py", line 126, in createserver     appengine_config = vmconfig.buildvmappengineenvconfig()   file "/home/vmagent/python_vm_runtime/google/appengine/ext/vmruntime/vmconfig.py", line 60, in buildvmappengineenvconfig     _metadatagetter('gae_backend_instance'))   file "/home/vmagent/python_vm_runtime/google/appengine/ext/vmruntime/vmconfig.py", line 37, in _metadatagetter     return urllib2.urlopen(req).read()   file "/usr/lib/python2.7/urllib2.py", line 127, in urlopen     return _opener.open(url, data, timeout)   file "/usr/lib/python2.7/urllib2.py", line 407, in open     response = meth(req, response)   file "/usr/lib/python2.7/urllib2.py", line 520, in http_response     'http', request, response, code, msg, hdrs)   file "/usr/lib/python2.7/urllib2.py", line 445, in error     return self._call_chain(*args)   file "/usr/lib/python2.7/urllib2.py", line 379, in _call_chain     result = func(*args)   file "/usr/lib/python2.7/urllib2.py", line 528, in http_error_default     raise httperror(req.get_full_url(), code, msg, hdrs, fp) urllib2.httperror: http error 404: not found 

what kind of configuration or actions can can run docker image inside of docker like:

sudo docker run gcr.io/my-project/ae-image 

another option me run ae in python don't know how can tell use production datastore (gcd). suppose that problem i'm having docker implementation above.

running application container standalone possible, there few nuances.

volume bindings
firstly, let's @ log directory part, create /var/log/appengine. when gcloud preview app run acts on container, runs volume bindings, map /var/log/appengine within container /var/log/appengine/(~additional paths here~) on host machine. if you're using boot2docker, can run boot2docker ssh , see server logs there.

environment variables
secondly, let's piece apart why application still not running. when application container starts, goes through few steps start app server. entrypoint whole process /home/vmagent/python_vm_runtime/vmboot.py, script in container run upon startup.

the problem script pulls information application several environment variables. if gcloud preview app run , start container way, can start shell in this:

$ gcloud preview app run <your_application.yaml> $ boot2docker ssh $ docker ps <output omitted - use find container id>  $ docker exec -ti <your_container_id> /bin/sh $ env api_port=10000 hostname=b758e92cb8d6 home=/root oldpwd=/home/vmagent/python_vm_runtime/google/appengine/ext gae_module_instance=0 path=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin debian_frontend=noninteractive module_yaml_path=app.yaml gae_partition=dev api_host=192.168.42.1 pwd=/home/vmagent/python_vm_runtime/google/appengine/ext/vmruntime gae_long_app_id=temp 

it turns out you're missing environment variable gae_module_instance=0. there's line in vmconfig.py says:

instance = (os.environ.get('gae_module_instance') or           _metadatagetter('gae_backend_instance')) 

in development mode, script needs work off environment variable, not _metadatagetter. ultimately, application container need of these environment variables, or continue break in other places.

so, can app running setting of environment variables when docker run. can -e flag. you'll need set quite few environment variables, suggest write shell script :-)


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -