Search code examples
node.jsdockerdockerfileopenshiftdocker-build

Can't install Nodejs 14 in a Dockerfile with Ubuntu 18.04 baseimage in Openshift


I currently have the problem that I can't install nodejs 14 in a dockerfile built via openshift. If I build it locally via Docker then it works without problems

I have curled the nodejs14 version via github but when I then "apt-get install nodejs -y" it always comes up with the message that nodejs cannot be found. As I said, that build works locally without problems with Docker. But I want to build this in Openshift because it is part of a pipeline that runs the built image. Here is the error message and the codelines.

Dockerfile Codelines:

# install nodejs
RUN curl -sL https://deb.nodesource.com/setup_14.x | bash - 
RUN apt-get install -y nodejs

Error

STEP 25/35: RUN curl -sL https://deb.nodesource.com/setup_14.x | bash -
time="2023-05-04T14:44:18Z" level=warning msg="Adding metacopy option, configured globally"
--> 446c42eb6c2
STEP 26/35: RUN apt-get install -y nodejs
Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package nodejs
error: build error: error building at STEP "RUN apt-get install -y nodejs": error while `enter code here`running runtime: exit status 100

When i update the packages via "apt-get update" i can install nodejs but with version 8.x.

Thanks in advance


Solution

  • change your "apt-get install -y nodejs" to this

     RUN apt-get update && apt-get install -y nodejs
    

    this will use the new repository and install nodejs14.