Problem
I'm using docker to generate my npm files. The problem is I get permissions issues when I do this. I have been using second alpine image to fix the permission issues. I want to speed up the process by generating the files with the correct permissions.
Attempt 1
Using the node user seemed to work at first as it persisted the user permissions on my device. When I tried it on a different device I got this error which I could not solve. The /local directory is where I'm mounting my npm directory. I also tried adding the group to the node user and got the same error.
Code
docker run -u "node" --rm -v $PWD:/local node:19.3.0 bash -c "cd local/mobile && npm install --legacy-peer-deps && npx ionic build && npx ionic cap copy"
Output
npm ERR! path /local/mobile/node_modules
npm ERR! errno -13 npm ERR!
Error: EACCES: permission denied, mkdir '/local/mobile/node_modules'
npm ERR! [Error: EACCES: permission denied, mkdir
'/local/mobile/node_modules']
{ npm ERR! errno: -13,
npm ERR!
code: 'EACCES', npm ERR! syscall: 'mkdir',
npm ERR! path:
'/local/mobile/node_modules' npm ERR! }
Attempt 2
I also tried using my local id and group id to run the dockerfile. I got a different error when using this technique.
Code
docker run -u "$(id -u):$(id -g)" --rm -v $PWD:/local node:19.3.0 bash -c "cd local/mobile && npm install --legacy-peer-deps && npx ionic build && npx ionic cap copy"
Output
npm ERR! code EACCES
npm ERR! syscall mkdir
npm ERR! path /.npm npm
ERR! errno -13
You can try specifying the user node. By default, the user "node" haven not have written permission the host machine
You try the following method
docker run --rm -v $PWD:/local node:19.3.0 bash -c "cd local/mobile && npm install --legacy-peer-deps && npx ionic build && npx ionic cap copy"
Related
Hi I'm beginner with Docker
I use the Docker Desktop on Windows (Linux Containers) to manage containers and I need to create a container with a NestJs application.
I built the image containing the app but when I want to run a container with this image I get this error:
> helloworld#0.0.1 start /usr/src/app
> nest start
/usr/src/app/node_modules/.bin/nest: line 1: ../#nestjs/cli/bin/nest.js: not found
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! helloworld#0.0.1 start: `nest start`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the helloworld#0.0.1 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2020-05-12T09_10_04_973Z-debug.log
my Dockerfile is like this
FROM node:current-slim
WORKDIR /usr/src/app
RUN npm i -g #nestjs/cli
COPY package.json /usr/src/app/package.json
RUN npm install
COPY . .
EXPOSE 3000
CMD ["sh", "-c", "npm run start"]
With this dockerfile it's working on Linux but on Windows I get the error.
I tried to use nestjs official docker image instead of node but I get same error.
I am trying to make a docker image including newman. I tried to build the image using node:10-alpine, but I got connection refused error while npm install -g newman. This is my docker command:
RUN set http_proxy= && \
set https_proxy= && \
yarn config delete proxy && \
npm config rm https-proxy && \
npm config rm proxy && \
npm config set registry http://registry.npmjs.org/ && \
npm config set strict-ssl false && \
npm cache clean --force && \
npm cache verify && \
npm install -g newman
The full error is:
npm ERR! code ECONNREFUSED
npm ERR! errno ECONNREFUSED
npm ERR! FetchError: request to https://registry.npmjs.org/newman failed, reason: connect ECONNREFUSED 192.168.14.109:1087
npm ERR! at ClientRequest.req.on.err (/usr/local/lib/node_modules/npm/node_modules/node-fetch-npm/src/index.js:68:14)
npm ERR! at ClientRequest.emit (events.js:198:13)
npm ERR! at onerror (/usr/local/lib/node_modules/npm/node_modules/agent-base/index.js:101:9)
npm ERR! at callbackError (/usr/local/lib/node_modules/npm/node_modules/agent-base/index.js:123:5)
npm ERR! at process._tickCallback (internal/process/next_tick.js:68:7)
npm ERR! { FetchError: request to https://registry.npmjs.org/newman failed, reason: connect ECONNREFUSED 192.168.14.109:1087
npm ERR! at ClientRequest.req.on.err (/usr/local/lib/node_modules/npm/node_modules/node-fetch-npm/src/index.js:68:14)
npm ERR! at ClientRequest.emit (events.js:198:13)
npm ERR! at onerror (/usr/local/lib/node_modules/npm/node_modules/agent-base/index.js:101:9)
npm ERR! at callbackError (/usr/local/lib/node_modules/npm/node_modules/agent-base/index.js:123:5)
npm ERR! at process._tickCallback (internal/process/next_tick.js:68:7)
npm ERR! message:
npm ERR! 'request to https://registry.npmjs.org/newman failed, reason: connect ECONNREFUSED 192.168.14.109:1087',
npm ERR! type: 'system',
npm ERR! errno: 'ECONNREFUSED',
npm ERR! code: 'ECONNREFUSED',
npm ERR! stack:
npm ERR! 'FetchError: request to https://registry.npmjs.org/newman failed, reason: connect ECONNREFUSED 192.168.14.109:1087\n at ClientRequest.req.on.err (/usr/local/lib/node_modules/npm/node_modules/node-fetch-npm/src/index.js:68:14)\n at ClientRequest.emit (events.js:198:13)\n at onerror (/usr/local/lib/node_modules/npm/node_modules/agent-base/index.js:101:9)\n at callbackError (/usr/local/lib/node_modules/npm/node_modules/agent-base/index.js:123:5)\n at process._tickCallback (internal/process/next_tick.js:68:7)' }
npm ERR!
npm ERR! If you are behind a proxy, please make sure that the
npm ERR! 'proxy' config is set properly. See: 'npm help config'
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2020-03-02T14_57_46_444Z-debug.log
Then I tried to make my image from alpine:3.8 which gives me repository error while apk update. This is my second version:
RUN apk update && apk add --no-cache nodejs npm
RUN npm install -g newman
Full error log is:
Step 5/7 : RUN apk update && apk add --no-cache nodejs npm
---> Running in 6149b2571389
fetch http://dl-cdn.alpinelinux.org/alpine/v3.8/main/x86_64/APKINDEX.tar.gz
ERROR: http://dl-cdn.alpinelinux.org/alpine/v3.8/main: operation timed out
WARNING: Ignoring APKINDEX.adfa7ceb.tar.gz: No such file or directory
fetch http://dl-cdn.alpinelinux.org/alpine/v3.8/community/x86_64/APKINDEX.tar.gz
ERROR: http://dl-cdn.alpinelinux.org/alpine/v3.8/community: operation timed out
WARNING: Ignoring APKINDEX.efaa1f73.tar.gz: No such file or directory
2 errors; 13 distinct packages available
The command '/bin/sh -c apk update && apk add --no-cache nodejs npm' returned a non-zero code: 2
I also tried to build the image with --network=hostoption; but got the same errors in both versions.
Additionally ping dl-cdn.alpinelinux.org works fine on my system.
Besides, restarted the docker service, sudo systemctl restart docker, and tried one more time. Got the same results again.
In my case works with this steps:
In the Host, I change Host Server
/etc/sysctl.conf:
I added
net.ipv4.ip_forward=1
I use
nslookup registry.npmjs.org
Give me the IP 104.16.25.38
Docker Build with IP
docker build . --add-host registry.npmjs.org:104.16.25.38 -t test
In my case works with this below single step,
docker build --add-host registry.npmjs.org:104.16.25.38 -t .
I have dockerfile containing the angular build section as below.
RUN apt-get update && apt-get install -y curl
RUN curl -sL https://deb.nodesource.com/setup_12.x | bash -
RUN apt-get install -y nodejs
RUN npm config set registry https://shnexus0.sohard.de/repository/sedi.npm.development/
RUN npm i -g #angular/cli#latest
RUN npm install
RUN npm install -g typescript
In the jenkins pipeline build I am getting the below error.
error TS2307: Cannot find module '#angular/core'.
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! dicom-web-viewer#0.0.0 tsc: `tsc`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the dicom-web-viewer#0.0.0 tsc script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?
Even though I have npm install in the dockerfile. It is showing the error for node module. Thanks in advance.
After allot of ado I was able to build my dockerimage, but when I try and run it I get the following error:
$ docker run swipeimage
> uswipe-merchant#0.0.1 dev /var/app
> NODE_ENV=development quorra ride --watch --env development
sh: quorra: not found
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! uswipe-merchant#0.0.1 dev: `NODE_ENV=development quorra ride --watch --env development`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the uswipe-merchant#0.0.1 dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2018-12-05T10_01_14_455Z-debug.log
I tried adding RUN npm install quorrato my docker file to make sure quorra is installed but still get an error.
Finally got it, I was looking at the quorra docs, and I changed
RUN npm install quorra
to
RUN npm install -g quorra-cli
Now it works!!!
Thanks All
I am attempting to run the Electron Quick Start in a Docker container with X11 forwarding. I've got all the appropriate packages figured out but when I run the container I get No protocol specified. I'm not sure what I'm missing to get it to work.
Dockerfile
FROM node
RUN apt-get update
RUN apt-get -y install libgtkextra-dev libgconf2-dev libnss3 libasound2 libxtst-dev libxss1 libx11-xcb-dev
WORKDIR /srv
ADD . .
RUN npm install
ENTRYPOINT ["npm", "start"]
Build and Run
docker build -t electron .
docker run -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=$DISPLAY electron
Output
npm info it worked if it ends with ok
npm info using npm#4.1.2
npm info using node#v7.7.2
npm info lifecycle electron-quick-start#1.0.0~prestart: electron-quick-start#1.0.0
npm info lifecycle electron-quick-start#1.0.0~start: electron-quick-start#1.0.0
> electron-quick-start#1.0.0 start /srv
> electron .
No protocol specified
npm info lifecycle electron-quick-start#1.0.0~start: Failed to exec start script
npm ERR! Linux 4.8.0-41-generic
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "start"
npm ERR! node v7.7.2
npm ERR! npm v4.1.2
npm ERR! code ELIFECYCLE
npm ERR! electron-quick-start#1.0.0 start: `electron .`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the electron-quick-start#1.0.0 start script 'electron .'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the electron-quick-start package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! electron .
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs electron-quick-start
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls electron-quick-start
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /srv/npm-debug.log
Q: What is the correct way of running Electron apps inside Docker?
In your host machine run xhost local:root then try running your container to run electron