在托管虚拟机的本地开发环境中运行Web应用程序时出现appengine.NewContext错误

I am trying to run one of the demos of the appengine using managed vm locally in my development environment. The requests fail with a panic when the code tries to create a new context for the request (appengine.NewContext(r)):

func handle(w http.ResponseWriter, r *http.Request) {
   if r.URL.Path != "/" {
    http.NotFound(w, r)
    return
   }

   c := appengine.NewContext(r)
   log.Infof(c, "Serving the front page.")
   tmpl.Execute(w, time.Since(initTime))
}

The appengine.NewContext(r) produces this error:

2015/05/30 01:01:27 appengine: NewContext passed an unknown http.Request 
2015/05/30 01:01:27 http: panic serving 192.168.59.3:51889: appengine: NewContext passed an unknown http.Request 
goroutine 115 [running]: 
net/http.func·011() 
 /usr/local/go/src/net/http/server.go:1130 +0xbb 
log.Panic(0xc2080c6b10, 0x1, 0x1) 
 /usr/local/go/src/log/log.go:307 +0xb9 
google.golang.org/appengine/internal.WithContext(0x7f7072110508, 0xc20800a380, 0xc208031110, 0x0, 0x0) 
 google.golang.org/appengine/internal/api.go:247 +0x158 
google.golang.org/appengine.WithContext(0x7f7072110508, 0xc20800a380, 0xc208031110, 0x0, 0x0) 
 google.golang.org/appengine/appengine.go:35 +0x4e 
google.golang.org/appengine.NewContext(0xc208031110, 0x0, 0x0) 
 google.golang.org/appengine/appengine.go:28 +0x7f 
main28149.handle(0x7f70721103d0, 0xc208062d20, 0xc208031110) 
 helloworld.go:28 +0x8f 
net/http.HandlerFunc.ServeHTTP(0x8662e0, 0x7f70721103d0, 0xc208062d20, 0xc208031110) 
 /usr/local/go/src/net/http/server.go:1265 +0x41 

net/http.(*ServeMux).ServeHTTP(0xc208038e40, 0x7f70721103d0, 0xc208062d20, 0xc208031110) 
 /usr/local/go/src/net/http/server.go:1541 +0x17d 
net/http.serverHandler.ServeHTTP(0xc2080600c0, 0x7f70721103d0, 0xc208062d20, 0xc208031110) 
 /usr/local/go/src/net/http/server.go:1703 +0x19a 
net/http.(*conn).serve(0xc208062c80) 
 /usr/local/go/src/net/http/server.go:1204 +0xb57 
created by net/http.(*Server).Serve 
 /usr/local/go/src/net/http/server.go:1751 +0x35e

The Dockerfile is:

FROM gcr.io/google_appengine/go-compat
RUN rm -rf /goroot && mkdir /goroot && curl https://storage.googleapis.com/golang/go1.4.2.linux-amd64.tar.gz | tar xvzf - -C /goroot --strip-components=1
ADD . /app
RUN /bin/bash /app/_ah/build.sh

It seems like the appengine environment is not properly set up in the docker image.

I would appreciate any suggestion about how to solve this problem.

Thanks!

from Go App Engine for Managed VMs

appengine.Context has been replaced with the Context type from golang.org/x/net/context.