docker-lambda
docker-lambda copied to clipboard
Cannot find module '/var/task/index' on windows 7
I installed docker toolbox on windows 7. When I run
docker run -v /d/projects/lambda/helloworld:/var/task lambci/lambda
I got the following error
{"errorMessage":"Cannot find module '/var/task/index'","errorType":"Error","stackTrace":["Function.Module._load (module.js:276:25)","Module.require (module.js:353:17)","require (internal/module.js:12:17)"]}
I googled but could not find out the solution.
The docker file for lambci/lambda has
ENTRYPOINT ["/var/lang/bin/node", "--max-old-space-size=1228", "--max-semi-space-size=77", "--max-executable-size=154", "--expose-gc", "/var/runtime/node_modules/awslambda/index.js"]
But why it is looking for /var/task/index? And I mounted my source code folder to /var/task, why it can not find it?
I always cd to the directory and specify the function when run locally on windows
docker run -v %cd%:/var/task lambci/lambda:$platform $file.$function $event
e.g. docker run -v %cd%:/var/task lambci/lambda:python2.7 handler.dostuff {"data": ... }
The $PWD bit was the problem for me (%cd%) in the respons above. I had to replace it with my absolute path using forward slashes.