brenden / node-webshot

Easy website screenshots in Node.js
2.12k stars 286 forks source link

Error: spawn Unknown system error -8 in dockerized node service #192

Closed koliada closed 7 years ago

koliada commented 7 years ago

Hi,

I have dockerized node service in which I want to use webshot. With all options to default, I get Error: spawn Unknown system error -8.

webshot('<url>', 'capture.png', (err) => {...};

I suspect that it might have something to do with how Docker handles processes, but still couldn't figure out what's the exact error to proceed.

Maybe you have any ideas? Thanks.

batiste commented 7 years ago

I have the same problem. How did you resolve it?

koliada commented 7 years ago

@batiste Don't remember exactly. But I ended up installing phantomjs globally in Dockerfile:

RUN npm i phantomjs@2.1.1 -g

and changing webshot config correspondingly:

phantomPath: '/usr/local/lib/node_modules/phantomjs/lib/phantom/bin/phantomjs',

This seems to resolve the issue. I guess it has something to do with permissions. Installing it globally seems to make it executable under the same user container is built.

idchlife commented 7 years ago

For those who came here after stumbling upon this error using nightmarejs within node alpine image: just use simple node image, lol that's the fastest way to solve the issue with

Error: spawn Unknown system error -8
dsagal commented 5 years ago

One reason this error may happen is if you spawn() is trying to run a non-Linux binary. E.g. if you package files from a Mac into your Docker container, and they include a native binary.