0

I have the following Python code written as part of an AWS Lambda:

import json
import os
def lambda_handler(event, context):
    os.system("docker cp panaxeaA1/ panaxea:app/phdcode")
    return {
        'statusCode': 200,
        'body': json.dumps('Hello from Lambda!')
    }

Which returns the following error:


16:21:23
START RequestId: 5693fd73-debb-11e8-9a71-ff6726b7be00 Version: $LATEST

16:21:23
sh: docker: command not found

16:21:23
END RequestId: 5693fd73-debb-11e8-9a71-ff6726b7be00

16:21:23
REPORT RequestId: 5693fd73-debb-11e8-9a71-ff6726b7be00  Duration: 16.04 ms  Billed Duration: 100 ms Memory Size: 128 MB Max Memory Used: 18 MB
No newer events found at the moment. Retry.

Docker is installed on the instance though... Any advice? I was under the impression I could make cmd calls via python?

1
  • 1
    Can you elaborate on what you mean by "Docker is installed on the instance"? Commented Nov 2, 2018 at 18:33

1 Answer 1

2

Docker is installed on the instance though... Any advice? I was under the impression I could make cmd calls via python?

Which "instance" are you talking about?! You are not executing your lambda function on your own instance!

According to the documentation:

[...]When a Lambda function is invoked, AWS Lambda launches an execution context based on the configuration settings you provide. The execution context is a temporary runtime environment that initializes any external dependencies of your Lambda function code[...] -> https://docs.aws.amazon.com/lambda/latest/dg/running-lambda-code.html

In order to call commands you have to install/embbed the packages your function needs into your lambda deployment package. See: https://docs.aws.amazon.com/lambda/latest/dg/lambda-python-how-to-create-deployment-package.html

Hope it helps!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.