-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sam build with --use container doesn't work if sam is running inside a container #2863
Comments
Do you have a "requirements.txt" file in your function's "CodeUri" directory? |
Yes I do have the requirements.txt in the |
Your
Can you post the snippet of your template file responsible for the function "KafkaLagLambdaFn?" |
Update: I managed to reproduce this error running sam in the docker. It has something to do with how docker mount volumes: https://stackoverflow.com/questions/31381322/docker-in-docker-cannot-mount-volume |
Hi all, @aahung I got the same error with a nodejs Lambda :
As you said sam is not really to blame here, it's a docker-in-docker catch : the sam container is trying to bind mount the working dir. But the mount path has to be correct from the host perspective, and chances are that's not possible without doing nasty things (like recreating the docker volume driver path/filesystem in the container). One nice thing would be able to add additional docker volumes to a sam container (should we add a feature request ?). That's almost already implemented but not available in the SAM build CLI interface. The nice thing about named docker volumes are that they don't suffer from the host path perspective "problem". Finally, what I recommend to fix this issue if you are running sam in a CI/CD container runner : don't use your usual Docker image for your CI/CD container runner docker executor and directly use AWS SAM lambda container images (the images ran if you specify |
This is also a problem when building functions that use container images (https://docs.aws.amazon.com/lambda/latest/dg/images-create.html). |
I am trying to build my lambda package inside a container with latest aws-sam-cli installed. Consider a scenario with a Jenkins or any CI server running inside containers.
Here are the reproduction steps:
docker run -v /var/run/docker.sock:/var/run/docker.sock -ti --entrypoint bash samcli:latest
sam build -u -t template.yml
--use-container
optionRequirements file not found: /tmp/samcli/source/requirements.txt
The text was updated successfully, but these errors were encountered: