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?
-
1Can you elaborate on what you mean by "Docker is installed on the instance"?jarmod– jarmod2018年11月02日 18:33:47 +00:00Commented Nov 2, 2018 at 18:33
1 Answer 1
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!