Closed NickDarvey closed 5 years ago
Might be easiest to open an interactive Docker session and see what's going on.
You can do that with:
docker run --rm -it -v /c/Users/me/source/repos/my-test-lambda:/var/task --entrypoint bash lambci/lambda:python2.7
Then you can have a look around at the filesystem and permissions – and compare them with the COPY
situation
Any luck with the above?
Unfortunately I've had to move on from this. If I recall correctly, the permissions I could see with ls -la
looked the same with each method. 😅 I'm sorry I can't clarify further
We found python-lambda-local ended up doing the trick, though we'd rather be using this to accurately emulate the environment. Hopefully I can reopen this sometime in the future!
I know this is a closed issue but one thing that is worth a try is to check your docker settings/shared drives. As you said. When you copy the files into the container it works. If you mount it, it doesn't work because docker does not have the authority to access your drive by default afaik. I faced the problem when I changed my OS login credentials and docker no longer had access to my drives.
Hi,
I'm having trouble importing local Python modules when using volume binding.
I understand the Python library I'm trying to use in my example is unrelated to lambci/lambda, but I am opening this here because it does work when I
COPY
the files into the Docker image, but not when I use volume binding.(I'm not so familiar with this ecosystem, so forgive my use incorrect terminology or misunderstanding.)
Repro
Download from here, or
Create a file,
lambda.py
Test 1
Dockerfile
docker build -t plz .
docker run --rm plz lambda.handler
Test 2
docker run --rm -v /c/Users/me/source/repos/my-test-lambda:/var/task lambci/lambda:python2.7 lambda.handler
Expected
Actual
System Info
What I've tried
os.listdir
,open()
(So I don't think it's the same as #114.)ldd
, all of the depdencies seem to resolve and refer to the same libraries. Comparing the working:docker run --rm --entrypoint ldd fusv /var/task/lib/python2.7/site-packages/osgeo/_gdal.so
with the not working:docker run --rm -v /c/Users/me/source/repos/my-test-lambda:/var/task --entrypoint ldd lambci/lambda:python2.7 /var/task/lib/python2.7/site-packages/osgeo/_gdal.so
docker run --rm -e "LD_LIBRARY_PATH=/var/task/lib/python2.7/site-packages:/lib64:/usr/lib64:/var/runtime:/var/runtime/lib:/var/task:/var/task/lib:/opt/lib" -v /c/Users/me/source/repos/my-test-lambda:/var/task lambci/lambda:python2.7 lambda.handler