Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-52656

Pod fails to create a Nodejs container

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      Trying to tun a podTemaplate with the following containerTemplate, we get the following error:

      npm ERR! path /home/jenkins/package.json
      npm ERR! code ENOENT
      npm ERR! errno -2
      npm ERR! syscall open
      npm ERR! enoent ENOENT: no such file or directory, open '/home/jenkins/package.json'
      npm ERR! enoent This is related to npm not being able to find a file.
      npm ERR! enoent

      npm ERR! A complete log of this run can be found in:
      npm ERR! /home/jenkins/.npm/_logs/2018-07-18T10_27_32_822Z-debug.log

       

      Configurations:

      Jenkinsfile PodTemplate:

       
      deftestpod="testpod-${UUID.randomUUID().toString()}"
      podTemplate(label: testpod, containers: [
      containerTemplate(
      name: 'myContainer',
      image: 'gcr.io/xxx/xxxs/zzz:latest',
      alwaysPullImage: true
      )],
      volumes: [
      hostPathVolume(hostPath: '/var/run/docker.sock', mountPath: '/var/run/docker.sock')
      ])
          {
      try{
      node(testpod) {
      stage ("checkout") {
      container('myContainer') {
      checkout scm
      }
      }
      ...
       
      zzz dockerfile:

      FROM node:8.9.4-alpine
      RUN mkdir -p /usr/src/app

      WORKDIR /usr/src/app

      COPY package.json /usr/src/app/
      ARG NODE_ENV
      ENV NODE_ENV $NODE_ENV

      1. Add packages needed to build native dependencies
        RUN apk add --no-cache --virtual .gyp \
        python \
        make \
        g++ \
        git \
        && npm install --quit && npm cache clean --force \
        && apk del .gyp

      RUN apk add --no-cache vim curl
      COPY . .

      EXPOSE 8888
      CMD [ "npm", "start"]
       

        Attachments

          Activity

          Hide
          csanchez Carlos Sanchez added a comment -

          /home/jenkins is mounted as a volume

          Show
          csanchez Carlos Sanchez added a comment - /home/jenkins is mounted as a volume
          Hide
          gilbl Gil Blau added a comment - - edited

          Carlos Sanchez - In Jenkins UI, yes we have mounted this path as the home directory, so I believe this path (=/home/jenkins) is mounted.

          But:
          1. Why this mounted volume effects the container?

          2. Does the plugin do anything besides "docker run <docker id>"? I am asking this because I don't understand why it is running "nmp install"...
          3. Can you please suggest how can this be fixed?

           

          BTW - If I add a working directory to the containerTemplate I get the same error with the working directory path:

          working directory configuration:
          workingDir: '/usr/src/app',
           

          Err msg:

          kubectl logs -f -c workers jenkins-slave-4tfz2-3nw6d -n jenkins
          npm ERR! path /usr/src/app/package.json
          npm ERR! code ENOENT
          npm ERR! errno -2
          npm ERR! syscall open
          npm ERR! enoent ENOENT: no such file or directory, open '/usr/src/app/package.json'
          npm ERR! enoent This is related to npm not being able to find a file.
          npm ERR! enoent

           

          Thanks!!

          Show
          gilbl Gil Blau added a comment - - edited Carlos Sanchez - In Jenkins UI, yes we have mounted this path as the home directory, so I believe this path (=/home/jenkins) is mounted. But: 1. Why this mounted volume effects the container? 2. Does the plugin do anything besides "docker run <docker id>"? I am asking this because I don't understand why it is running "nmp install"... 3. Can you please suggest how can this be fixed?   BTW - If I add a working directory to the containerTemplate I get the same error with the working directory path: working directory configuration: workingDir: '/usr/src/app',   Err msg: kubectl logs -f -c workers jenkins-slave-4tfz2-3nw6d -n jenkins npm ERR! path /usr/src/app/package.json npm ERR! code ENOENT npm ERR! errno -2 npm ERR! syscall open npm ERR! enoent ENOENT: no such file or directory, open '/usr/src/app/package.json' npm ERR! enoent This is related to npm not being able to find a file. npm ERR! enoent   Thanks!!
          Hide
          gilbl Gil Blau added a comment -

          Carlos Sanchez - can you please assist or point me to a forum where a community can assist?

          Show
          gilbl Gil Blau added a comment - Carlos Sanchez - can you please assist or point me to a forum where a community can assist?
          Hide
          csanchez Carlos Sanchez added a comment -

          jenkins-users mailing list

          Show
          csanchez Carlos Sanchez added a comment - jenkins-users mailing list
          Hide
          gilbl Gil Blau added a comment -

          Carlos Sanchez - can you please try assisting me with this issue? I am clueless how to resolve this issue.

          Show
          gilbl Gil Blau added a comment - Carlos Sanchez - can you please try assisting me with this issue? I am clueless how to resolve this issue.

            People

            Assignee:
            csanchez Carlos Sanchez
            Reporter:
            gilbl Gil Blau
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: