Skip to content

Permission denied when trying to run function #428

@BenAychh

Description

@BenAychh

Whenever I run sam local invoke Hello <<< "{}" or sam local start-api -d 5858 and try to invoke my function, I am getting the following stack trace.

Steps to reproduce the issue:

  1. I am using this repo here: https://github.com/BenAychh/school-ticket-sales-api-discovery
  2. sam local invoke Hello <<< "{}"

Observed result:

~/SchoolTicketSales/service-discovery >>> sam local invoke Hello <<< "{}"                                                                                                                                ±[master]
2018-05-22 17:26:46 Reading invoke payload from stdin (you can also pass it from file with --event)
2018-05-22 17:26:46 Invoking com.serverless.Handler (java8)
2018-05-22 17:26:46 Found credentials in shared credentials file: ~/.aws/credentials
2018-05-22 17:26:46 Decompressing /home/ben/SchoolTicketSales/service-discovery/target/hello-dev.jar

Fetching lambci/lambda:java8 Docker container image......
2018-05-22 17:26:48 Mounting /tmp/tmpzDMLCv as /var/task:ro inside runtime container
Traceback (most recent call last):
  File "/home/ben/.local/bin/sam", line 11, in <module>
    load_entry_point('aws-sam-cli==0.3.0', 'console_scripts', 'sam')()
  File "/home/ben/.local/lib/python2.7/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/home/ben/.local/lib/python2.7/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/home/ben/.local/lib/python2.7/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/ben/.local/lib/python2.7/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/ben/.local/lib/python2.7/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/ben/.local/lib/python2.7/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/home/ben/.local/lib/python2.7/site-packages/click/decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args[1:], **kwargs)
  File "/home/ben/.local/lib/python2.7/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/home/ben/.local/lib/python2.7/site-packages/samcli/commands/local/invoke/cli.py", line 44, in cli
    docker_network, log_file, skip_pull_image, profile)  # pragma: no cover
  File "/home/ben/.local/lib/python2.7/site-packages/samcli/commands/local/invoke/cli.py", line 76, in do_cli
    stderr=context.stderr)
  File "/home/ben/.local/lib/python2.7/site-packages/samcli/commands/local/lib/local_lambda.py", line 80, in invoke
    stdout=stdout, stderr=stderr)
  File "/home/ben/.local/lib/python2.7/site-packages/samcli/local/lambdafn/runtime.py", line 83, in invoke
    self._container_manager.run(container)
  File "/home/ben/.local/lib/python2.7/site-packages/samcli/local/docker/manager.py", line 63, in run
    container.start(input_data=input_data)
  File "/home/ben/.local/lib/python2.7/site-packages/samcli/local/docker/container.py", line 167, in start
    real_container.start()
  File "/home/ben/.local/lib/python2.7/site-packages/docker/models/containers.py", line 374, in start
    return self.client.api.start(self.id, **kwargs)
  File "/home/ben/.local/lib/python2.7/site-packages/docker/utils/decorators.py", line 19, in wrapped
    return f(self, resource_id, *args, **kwargs)
  File "/home/ben/.local/lib/python2.7/site-packages/docker/api/container.py", line 1063, in start
    self._raise_for_status(res)
  File "/home/ben/.local/lib/python2.7/site-packages/docker/api/client.py", line 227, in _raise_for_status
    raise create_api_error_from_http_exception(e)
  File "/home/ben/.local/lib/python2.7/site-packages/docker/errors.py", line 31, in create_api_error_from_http_exception
    raise cls(e, response=response, explanation=explanation)
docker.errors.APIError: 400 Client Error: Bad Request ("OCI runtime create failed: container_linux.go:348: starting container process caused "chdir to cwd (\"/var/task\") set in config.json failed: permission denied": unknown")

Expected result:
The function to run.

Additional environment details (Ex: Windows, Mac, Amazon Linux etc)

Manjaro Linux
Docker version 18.04.0-ce, build 3d479c0af6

docker containers (I assume are being run)
lambci/lambda latest 6ad25a1b8bf1 10 days ago 968MB
lambci/lambda java8 674182a5353c 10 days ago 940MB

Output of sam --version:

SAM CLI, version 0.3.0

Optional Debug logs:

Add --debug flag to command you are running

Metadata

Metadata

Assignees

No one assigned

    Labels

    blocked/more-info-neededMore info is needed from the requester. If no response in 14 days, it will become stale.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions