Bruno Marques
Bruno Marques

Reputation: 109

Python error in serverless framework stating - Serverless Error: spawn docker ENOENT

Error:

Running "serverless" from node_modules

Deploying serverless-flask to stage dev (us-east-1)

✖ Stack serverless-flask-dev failed to deploy (0s)
Environment: darwin, node 16.0.0, framework 3.1.1 (local) 3.1.1v (global), plugin 6.0.0, SDK 4.3.1
Credentials: Local, "default" profile
Docs:        docs.serverless.com
Support:     forum.serverless.com
Bugs:        github.com/serverless/serverless/issues

Error:
Error: spawn docker ENOENT
    at Process.ChildProcess._handle.onexit (node:internal/child_process:282:19)
    at onErrorNT (node:internal/child_process:480:16)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)

I'm following these instructions (https://www.serverless.com/blog/flask-python-rest-api-serverless-lambda-dynamodb/) and can't seem to figure this out since the base app is in python and not javascript... most people who have solved this solved it using javascript.

Upvotes: 7

Views: 6433

Answers (2)

Bharat
Bharat

Reputation: 227

To solve this issue you need to update your serverless.yml file with these changes in the custom block

custom:
  pythonRequirements:
    pythonBin: python3
    dockerizePip: "false"

I also face the same issue my issue was with dockerizePip it was set to

dockerizePip: non-linux

either remove this entry from serverless.yml file or just set it to false

Upvotes: 7

TheSmartMonkey
TheSmartMonkey

Reputation: 1052

To be able to deploy your project with serverless-python-requirements you need to have docker on your machine (if you are on windows consider using docker desktop or a linux vm)

Why do I need Docker ?

When you do a sls deploy, serverless-python-requirements launch a docker container to install all the dependencies you've put in your requirements.txt file that will be used during the deployement process

You are getting this error because your container is not launch correctly

Upvotes: 6

Related Questions