'Error response from daemon: failed to create shim when installing Nodejs

I am trying to create a docker image with node.js version 16. However I failed to find solution to this problem despite searching stackoverflow and other platform.

So basically I am using docker compose up and this is how my docker-compose.yml looks like:

version: '3.1'

services:
    redis:
        image: 'redis:alpine'
        ports:
            - "6379:6379"

    webserver:
        image: 'nginx:alpine'
        working_dir: /application
        volumes:
            - '.:/application'
            - './docker/nginx/nginx.conf:/etc/nginx/conf.d/default.conf'
        ports:
            - '3000:80'

    php-fpm:
        build: docker/php-fpm
        working_dir: /application
        volumes:
            - '.:/application'
            - './docker/php-fpm/php-ini-overrides.ini:/etc/php/7.4/fpm/conf.d/99-overrides.ini'

    node:
        build: docker/node
        working_dir: /application
        volumes:
            - './:/application'
        ports:
            - '8080:8080'

The files are living in docker folder with 3 nested folders. node/Dockerfile:

FROM node:16

WORKDIR /application

COPY package*.json ./

RUN npm install

COPY . .

EXPOSE 8080

CMD ["npm", "start"]

The npm start command consists of npm install and a postinstall where simply npm run dev would be executed.

Unfortunatley, I get the following error

Error response from daemon: failed to create shim: OCI runtime create failed: container_linux.go:380: starting container process caused: exec: "/bin/sh -c 'cd /application && npm install'": stat /bin/sh -c 'cd /application && npm install': no such file or directory: unknown

Also I want to add is, I am running this under WSL2.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source