docker-node
docker-node copied to clipboard
Trying to use npm in docker image built with node:16-alpine3.16 or 3.15 and npm -v and all options fail
Environment
- Platform: kubernetes
- Docker Version:
- Node.js Version: v16.17.0
- Image Tag: not checked in at public repository (we have it in our own harbor repository
Expected Behavior
npm -v should return a version and it should accept options
Create a docker image and connecting to container and running npm -v shows a version However, running same image in kubernetes does not return any output when using any options.
Current Behavior
Create a docker image and connecting to container and running npm -v shows a version However, running same image in kubernetes does not return any output when using any options.
Create a docker image and connecting to container and running npm -v shows a version However, running same image in kubernetes does not return any output when using any options.
Possible Solution
I don't know
Steps to Reproduce
Build docker image and then use in kubernetes deployment
use node:16-alpine3.16 or 3.15 in dockerfile specify WORKDIR as /usr/src/app CMD [ "npm", "run" "start:activity" fails ]
used CMD [ "loop.sh" ] to get it in a loop so i could get on pod and run npm -v
npm -v pauses for a second and then drops down to command prompt with no message npm asfasdfsafg also drops down to command prompt with no mesage
Additional Information
kubernetes makes /usr/src/app read-only, and I think where ever npm is located is also read-only. I tried to copy npm's node_modules folder over to /tmp (read-write tempdir) and it still did same behavior.
Having no error or message or way to tell what is going on makes this difficult to troubleshoot.
Using node:latest allows npm -v to work by the way. This is not using the alpine though. We also had to comment out our adduser/addgroup commands to use this one, which maybe is not a big deal. We are seeing if our code that is really for node:16 will work with node:16.
18-alpine3.16 seems to work, so the issue seems to exist with just 16-apline3.16.
Not sure if I have the same issue ,but since Saturday (maybe the docker cache delayed it till then, issue could be existing longer) I have:
#6 0.417 c: applet not found
for all kind of different commands ,first it was npm itself, I added a RUN mkdir -p /usr/local/sbin && ln -s /usr/local/bin/node /usr/local/sbin/node
becaues somehow it wanted to access /usr/local/sbin instead of bin ... but now it even fails at "mkdir":
#8 transferring context: 67.45MB 0.7s done
#8 DONE 1.5s
#6 [stage-0 3/13] RUN mkdir -p /usr/local/sbin && ln -s /usr/local/bin/node /usr/local/sbin/node
#6 sha256:1c3bca9940f1632b84b676e3753d4b2c0c86e17f31f81270864fc713b479b489
#6 0.394 c: applet not found
#6 ERROR: executor failed running [/bin/sh -c mkdir -p /usr/local/sbin && ln -s /usr/local/bin/node /usr/local/sbin/node]: exit code: 127
For what it's worth, I'm seeing exactly the same failure when trying to run containers in Fargate. The problem occurs with node:16.15.1-alpine but not with node:16.15.0-alpine.
@varju have you had any luck with a later version of node 16 alpine? We also had to specify 16.15.0 in order to get our image working but I think we need to update in order to resolve a critical security bug.
It's been a while since I've thought about this issue; I believe it is closely related to #1737. I pinned my npm to 8.5.5, and have been able to use the latest node:lts-alpine without problem since then.
Thanks for the quick reply, seen as how the two vulnerabilities we have been asked to resolve are: critical zlib version 1.2.12-r0 has 1 vulnerability high npm version 8.5.5 has 1 vulnerability it seems pinning npm to 8.5.5 won't be a viable solution for us. I've subscribed to the issue you sent as that seems like the same problem we were having as well. Seems weird that this issue has been going on so long and isn't getting much traction.