When I am trying to run function locally I got error form docker:
sam local invoke "HelloWorldFunction" -e index.js
2017/08/12 13:03:27 0.1.0
2017/08/12 13:03:27 Successfully parsed template.yaml (version 2010-09-09)
2017/08/12 13:03:27 Connected to Docker 1.30
2017/08/12 13:03:27 Fetching lambci/lambda:nodejs4.3 image for nodejs4.3 runtime...
nodejs4.3: Pulling from lambci/lambda
Digest: sha256:1ec74ee2e5c71e231d87d9b961f4f310bf817088f4391763a37e5adb657c6038
Status: Image is up to date for lambci/lambda:nodejs4.3
2017/08/12 13:03:30 Invoking index.handler (nodejs4.3)
2017/08/12 13:03:30 Could not invoke function: Error response from daemon: create .: volume name is too short, names should be at least two alphanumeric characters
Some info about my local system:
docker -v
Docker version 17.06.0-ce, build 02c1d87
docker-compose -v
docker-compose version 1.14.0, build c7bdf9e
md5-1bf571096ae75654e0ffd5007a9516c9
ProductName: Mac OS X
ProductVersion: 10.12.6
BuildVersion: 16G29
pls let me know in case if you need more info
Can you post the HelloWorldFunction SAM definition too?
Looks like a Docker limitation moby/moby#20122. Docker doesn't allow mounting of directories with one character names. Is the directory where you are running sam from named with one character?
Hi @sanathkr
here is my task template its form awslabs/serverless-application-model repo.
AWSTemplateFormatVersion : '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: A hello world application.
Parameters:
Bucket:
Type: String
CodeZipKey:
Type: String
Resources:
HelloWorldFunction:
Type: AWS::Serverless::Function
Properties:
Handler: index.handler
Runtime: nodejs4.3
CodeUri:
Bucket: !Bucket
Key: !CodeZipKey
Yes it is a totally a docker issue.
But maybe './' can be used instead '.' when mounting current dir to container.
We convert directory reference to absolute path before mounting. So I don't see . being a problem. Did your directory contain a single char name?
@sanathkr I expect the same issue. Directory name is not single char.
As a workaround, you can specify the full path to the template with --template $(pwd)/template.yaml
I need to dig further into why the absolute path isn't being resolved. Im struggling to replicate this locally though. I know @ranman ran into this too.
I've experience this issue too using the S3 example. Specifying the --template mitigates the issue. Happy to provide more detail if that helps!
Ok - i've worked out the issue.
This happens if the CodeUri property is set, and not set to a relative directory. Quite a few of of the example templates have values such as s3://<bucket>/package.zip.
I'll submit a PR to get this fixed shortly, in the meantime removing the CodeUri property from your template will workaround the problem.
This is fixed in the pull request referenced above.
Once it's been reviewed and merged it will be fixed in the develop branch.
It will then get included in the next release we do (shouldn't be too long).
Most helpful comment
As a workaround, you can specify the full path to the template with --template $(pwd)/template.yaml
I need to dig further into why the absolute path isn't being resolved. Im struggling to replicate this locally though. I know @ranman ran into this too.