Docker-compose encountering difficulty executing shell script (npm / ng serve) due to inability to locate specified directory

I've configured my docker-compose file to handle the deployment of an Angular-CLI frontend and a directory called scripts.

  www:
    build: ./www
    volumes:
      - ./www/frontend:/app
      - ./www/scripts:/scripts
    command: /scripts/init-dev.sh
    ports:
      - "4200:4200"
      - "49153:49153"

Within the Dockerfile located in the www directory, npm is installed.

FROM node:10-alpine
RUN apk add --no-cache git make curl gcc g++ python2

RUN npm config set user 0
RUN npm config set unsafe-perm true

RUN npm install

Here's the content of the script:

#!/bin/bash
echo "Serving.."
cd /app && npm run-script start

When I execute the

docker-compose down && docker-compose build && docker-compose up
command, I encounter the following error message:

www_1       | standard_init_linux.go:190: exec user process caused "no such file or directory"

I suspect that the issue lies with the command line specified in the configuration.

Answer №1

It seems like the process may be out of sequence.

While I'm not well-versed in Node, it appears that you need a package.json or similar file for npm install to work properly. It's likely located in /app. However, during the build process, /app is not visible since it isn't specified in the Dockerfile.

Consider relocating npm install within the script to something like

cd /app && npm install && npm run-script start
.

Answer №2

I once faced a similar challenge, and my suggestion would be to grant execute permissions to the specified file.

chmod +x www/scripts/init-dev.sh

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Cannot complete npm install due to error: SocksProxyAgent is not recognized as a valid constructor

Error log: 50 warning: skipping integrity check for git dependency https://<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="a3c4cad7e3c4cad7cbd6c18dc0ccce">[email protected]</a>/jitsi/strophejs-plugin-stream-management.g ...

What is the process for modifying the output format of npm ls?

My client is requesting the dependencies of our projects, including the library name and github/NPM URL. Currently, I am using 'npm ll' command to retrieve this information for each project, but the output is in a tree structure. Is there a way t ...

Raspberry Pi experiences issues with PM2

I attempted to set up pm2 on a Raspberry Pi. I used the command sudo npm install -g pm2: pi@raspberrypi:~ $ sudo npm install -g pm2 /usr/bin/pm2 -> /usr/lib/node_modules/pm2/bin/pm2 /usr/bin/pm2-dev -> /usr/lib/node_modules/pm2/bin/pm2-dev /usr/bin/ ...

Issue with Webpack Build Excluding JSON Resource Files

My Webpack build is not including the resources folder in the dist build, resulting in the translation files not being picked up and causing the translations to not take place... File structure: dist //The json files from src/resources need to be incl ...

Challenges encountered while transitioning from Tailwind v2 to v3 in React Js with Craco

I encountered an issue while upgrading my Tailwind from version v2 to v3. The Postcss 8 Error (Error: PostCSS plugin tailwindcss requires PostCSS 8.) keeps popping up and despite my efforts, I haven't been able to resolve it. Is there a way for me to ...

I encounter numerous node errors every time I try to use node

It seems like there may be issues with node-related files on my machine, so I'm considering deleting everything related to it. Before doing so, I want to confirm. While attempting to create a script with commander, I ran npm install -g at one point. ...

What is the best way to assign a value to process.env within an npm script?

After creating a new Vue app (using Vite) with npm init vue@latest and selecting Playwright for e2e tests, the configuration file was generated with a field for setting headless mode: const config: PlaywrightTestConfig = { // ... use: { // ... ...

The download of nvm install v.8.9.1 version is not possible due to a checksum mismatch with clang, as well as a

I am in the process of setting up node version v8.9.1 because it is specifically required for the proper functioning of Hyperledger Fabric, as mentioned in this thread on github issues. Attempting to download and install node v8.9.1... Downloading https ...

Encountering an issue: "You need to be signed in. Please log in using `npm login` and attempt again." appears when attempting to release with NP

After creating a classic JavaScript package and integrating NP to streamline the publishing process, I encountered an issue when running the NP command with npm run np. The error message displayed was: npm ERR! code ENEEDAUTH npm ERR! need auth This comman ...

An error notification received from the command "jspm install jquery"

As I follow the tutorial on the jspm.io site, everything goes smoothly until I reach step 3. When I try to execute jspm install jquery, an error message pops up. The error reads: warn Error on getOverride for jspm:github, retrying (2). ReferenceError: ui ...

Using Vite for creating a production build: A step-by-step guide

Just getting started with Vite and ready to take it into production. I'm wondering how I can create scripts (specifically for docker) to successfully run it in a production environment. The documentation strongly advises against using the preview mod ...

Having trouble downloading the compression webpack plugin using npm, as it keeps throwing an error

Hey there, this message pops up when attempting to execute the following command: npm install compression-webpack-plugin Here is the accompanying error: `PS D:\phaser games\game-slot-machine> npm install compression-webpack-plugin npm ERR! ...

Travis is experiencing issues with retrieving the API key after logging in with npm

Referencing the information found at , it is stated that an API key should be visible after executing npm login. However, upon performing npm login (or npm adduser) and checking with cat .npmrc, I am unable to locate any indication of an API key. I would ...

The installed local Angular version is outdated compared to the current project version

I've been having trouble customizing my Angular CLI because a package I need only works with an older version of Angular. Currently, my global Angular version is 15.2.9. However, when I create a new Angular project using ng new, the package.json shows ...

Encountered an issue while building npm: "Error: Unable to locate module @restart/context

Lately, I've encountered an issue with npm build after upgrading to the latest version of react-bootstrap (1.0.0-beta.6). While creating an optimized production build... Failed to compile. Module not found: '@restart/context/forwardRef'. P ...

Installing packages globally and locally with npm leads to the installation of varying components

There seems to be a discrepancy in the results I get when installing a package with --global compared to a local installation. For instance I recently installed https://github.com/sverweij/dependency-cruiser $ npm install --save-dev dependency-cruiser W ...

encountered an error stating module '@angular/compiler-cli/ngc' could not be located while attempting to execute ng serve

Here is the content of my package.json file: { "name": "cal-euc", "version": "0.0.0", "scripts": { "ng": "ng", "start": "ng serve", "build&qu ...

What is the best way to silence deprecation warnings from npm/nvm in zsh?

I have incorporated nvm into my workflow to manage node versions by installing it as a plugin for zsh using zsh-nvm. Currently, I have two node versions installed - v6.1.0 and v0.10.42. As the project I am working on requires the latter version, I have set ...

Having trouble installing dependencies through npm while constructing a docker image

When building an image from a Dockerfile, I encountered an error during the npm installation part of the process. Strangely, I can run the commands successfully outside of the image build environment. The source of this error is still unknown to me. I am ...

Problem encountered while performing npm installation on Ubuntu due to ENOENT error with lstat

I've been working on a project that handles blog posts and recently deployed it on a cloud platform without any issues. However, I decided to clean up my node_modules folder by deleting it and reinstalling using npm install. After doing so, I encount ...