1

I am using node:12-alpine with a NodeJS backend calling ShellJS spawn command. It is supposed to run the shell script and I have verified and tested that it works locally. However, it is showing this error when it is running in the Docker container.

I have also verified that the script exists in the folder using docker exec.

Do I need to configure in alpine for this to work?

This is the command that ShellJS is calling: source execute.sh

Error: spawn /usr/src/app/scripts/execute.sh ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:267:19)
    at onErrorNT (internal/child_process.js:469:16)
    at processTicksAndRejections (internal/process/task_queues.js:84:21)
Emitted 'error' event on ChildProcess instance at:
    at Process.ChildProcess._handle.onexit (internal/child_process.js:273:12)
    at onErrorNT (internal/child_process.js:469:16)
    at processTicksAndRejections (internal/process/task_queues.js:84:21) {
  errno: 'ENOENT',
  code: 'ENOENT',
  syscall: 'spawn /usr/src/app/scripts/execute.sh',
  path: '/usr/src/app/scripts/execute.sh',
Exceptions
  • 1,174
  • 2
  • 9
  • 28
  • `source` isn't a standard shell command. `.` is, and means essentially the same thing as the non-standard `source` command that bash has. Running `source` or `.` in a spawned process is a little odd, though; can you include the code that's causing to this problem? – David Maze Jun 10 '20 at 10:07

1 Answers1

0

If you would like to use shell scripts in alpine you have to install a package called bash. It happens because alpine does not have a bash.

Alpine comes with ash as the default shell instead of bash.

Here is an example to install bash in you alpine image.

Dockerfile

FROM alpine:latest
RUN apk add --update \
nodejs \
nodejs-npm \
bash && rm -rf /var/cache/apk/*
# ...
Danizavtz
  • 3,166
  • 4
  • 24
  • 25