npm install fails in jenkins pipeline in docker

前端 未结 12 908
野性不改
野性不改 2020-12-07 17:45

I\'m following a tutorial about Jenkins pipeline and I can get a \"hello world\" working under at node 6.10 docker container.

But, when I added a default EmberJS app

12条回答
  •  -上瘾入骨i
    2020-12-07 18:01

    We had the same issue, the core of the problem for us was, that the user in the Container and the User running the Jenkins node had different UIDs. After changing the UID+GID of the user in the container (and changing ownership of the users home-directory) to match the user running the build node npm would behave normal.

    This might also happen if the Home-Directory of the container-user is not writeable.

    Code in the Dockerfile:

    RUN usermod -u   && \
        groupmod -g   && \
        chown -R : /home/
    

    As the Workspace is mounted into the container it will already belong to the UID. When running the container through the Jenkinsfile the UID and GID of the container user are set automatically to match the buildnode. But the home directory will still have its original owner.

    Now the node_modules will be placed in the current directory.

提交回复
热议问题