Skip to content

[BUG]node:16-alpine3.16 and npm -v and other npm options return no output when using image in kubernetes #5428

@mrdeshapiro

Description

@mrdeshapiro

Is there an existing issue for this?

  • I have searched the existing issues

This issue exists in the latest npm version

  • I am using the latest npm

Current Behavior

Hello,

With docker image creation, I updated to use FROM node:16-alpine3.16 for the image and used that image with kubernetes, but now for some reason npm -v does not return information.

Any command options I try does nothing. It pauses for a few seconds like it is thinking and then drops down to the command prompt with no output. I can even put in fake options and it does the same thing.

It worked fine with our previous use of node:14:alpine.

Note: that /usr/src/app becomes readonly once the container is made and used in kubernetes.

Using the image outside of kubernetes still works fine. Is npm trying to write now to /usr/src/app? How do I address this? In that, if I make do a docker build and then try and connect to the container to get to a comand prompt, I can npm -v fine. It is when I use this image in kubernetes that I have the bad behavior.

Finding who can help with this is kind of unclear. I am not sure if maybe something is going on with the read-only filesystem once in kubernetes. Have you seen this issue and do you have a suggestion on what might be going on and how to fix? Is there a way to have some debugging when I run the npm command so that I can see what it is doing while it pauses before dropping down to the command prompt?

Sincerely,

David

Expected Behavior

I expect to see npm -v return a version

Steps To Reproduce

create a standard dockerfile that uses:

FROM node:16-alpine3.16
You can do the typical WORKDIR /usr/src/app and copy your package* and code into it
I created a user with the same uid/gid I set as runasuser (1001)/runasgroup (3000) in my kubernetes deployment yaml
have CMD "./loop.sh" so it just loops and does hello world message during this troubleshooting. It is actually supposed to launch a web page with:

EXPOSE 3000

CMD ["npm", "run", "start:activity"]

I use kubectl exec -it /bin/sh to get on the pod and run npm -v.

Environment

npm config is not returning anything as it is now. No options sent to npm work.

npm is supposed to be 8.15.0
It is using alpine 3.16 (tried 3.15 too)

Note: node -v does return a version just fine.  It is whatever version is in the alpine build.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bugthing that needs fixingNeeds Triageneeds review for next stepsRelease 8.xwork is associated with a specific npm 8 release

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions