Search code examples
node.jsdockernpmdocker-composedocker-for-windows

Docker build failed | The command '/bin/sh -c node -v' returned a non-zero code: 4294967295 on windows


This is a basic Dockerfile that I am trying to build on windows docker. docker build . -t nishantt95/my-node-app

FROM node:16.14.2

WORKDIR /app
COPY package*.json ./

RUN npm i

COPY . ./

EXPOSE 3000
CMD ["npm", "start"]

Once it completes a RUN command, it prompts an error:

The command '/bin/sh -c npm i' returned a non-zero code: 4294967295: failed to shutdown container: container 89916be2224207b5aab466b1582a44a59c3375330feb698408b758f7adbcb996 encountered an error during hcsshim::System::waitBackground: failure in a Windows system call
: The virtual machine or container with the specified identifier is not running. (0xc0370110): subsequent terminate failed container 89916be2224207b5aab466b1582a44a59c3375330feb698408b758f7adbcb996 encountered an error during hcsshim::System::waitBackground: failure in
 a Windows system call: The virtual machine or container with the specified identifier is not running. (0xc0370110)

Soon I realized that I am facing this error with all the basic RUN command (e.g. RUN pwd, RUN node -v)


Solution

  • There is some issue building the container on windows, hence we need to switch to Linux containers.

    enter image description here

    Note: Windows might prompt you to install WSL2 so install that and restart your docker desktop. After that, rebuild your Dockerfile and it will work as expected.