Right now I am having to build my own custom docker image from lambci/lambda:nodejs6.10 because I would like some additional stuff added to the image. Im looking to use my custom docker image with the sam local invoke command for running with this custom docker image.
I have a similar ask, but (I think) for different reasons.
As of today the version of boto3 included in lambci/lambda:python3.6 is out of date.
I've cut and paste my function which fails under SAM Local into a AWS Lambda function which succeeds.
To try and remedy this; I pulled the Dockerfile from lambci/docker-lambda to build the images, and added pip, and pip install boto3 --upgrade.
This gets me an image locally that contains the latest version of Boto3, however I don't think I can run this via Sam. Sam seems to ignore my image which is tagged lambci/lambda:python3.6 and gets the version from Dockerhub.
It would be valuable to be able to specify our own Lambda images. Especially if there will be drift between the lambci images and the environment found in AWS Lambda.
Thanks!
Same here, i've made some tweaks to lambci/lambda:nodejs6.10 to work with my testing setup but sam ignores it and uses the one from DockerHub
After modifying the image, you can run with the --skip-pull-image flag, then it won't pull from DockerHub. If successful, it will print Requested to skip pulling images ...
I don't believe allowing customer docker images is something we should be supporting. The docker instances should be the same (or as close as they can be) to the Lambda runtime containers. Allowing customer containers defeats this and pushes you farther away from having fidelity with the Lambda Service itself.
To @apmclean reason, the recommendation from Lambda is to package all you dependencies in your zip. This includes boto3 and other libraries installed on the instances. SAM CLI is no different.
Closing
Not everyone has the luxury of working in an environment that allows developers to pull public docker images.
In order to get sam to use our organizations docker repo I patched the sam entrypoint to override the default repo name.
IE on macOS I edited the $HOMEBREW_DIR/bin/sam file and added:
from samcli.local.docker.lambda_image import LambdaImage
LambdaImage._DOCKER_LAMBDA_REPO_NAME = "my-org-repo.local/lambda"
I also work for an organization that blocks access to public docker repositories like docker hub. Most security conscious enterprises do this. Can we please reopen this issue @jfuss?
Most helpful comment
Not everyone has the luxury of working in an environment that allows developers to pull public docker images.
In order to get sam to use our organizations docker repo I patched the sam entrypoint to override the default repo name.
IE on macOS I edited the
$HOMEBREW_DIR/bin/samfile and added: