How to set user in docker image? Bee Bot July 13, 2022 11:41 Updated The content of this article has moved to the new documentation site. Related articles Pipeline builds using docker.image.inside fail after upgrade Issues Pipeline - Parallel execution of tasks How To Authenticate to AWS with the Pipeline AWS Plugin does not seem to be running inside a container Comments 3 comments Sort by Date Votes Gabriel Fdc May 16, 2017 03:11 This doesn't work, as the shell step would run outside of the docker image as it is said in https://go.cloudbees.com/docs/cloudbees-documentation/cje-user-guide/index.html#docker-workflow-sect-run So, if you have a jenkins with no nodejs, and would try to do a build inside the node docker image if you use this method: docker.image('node').withRun('-u node'){ sh 'node -v' sh 'npm install'} you will get node: command not found But if you try to do it inside the docker image: docker.image('node').inside(){ sh 'node -v' sh 'npm install'} you would get the error described in the article: npm ERR! Error: EACCES: permission denied, mkdir '/.npm' is there a way to specify the user to docker and run something inside the image? 0 Denys Digtiar May 16, 2017 05:34 Hi Gabriel, Please try the following since `inside` method supports parameters in a similar way as `withRun` docker.image('node').inside('-u node') { sh 'node -v' sh 'npm install'} 0 Gabriel Fdc May 16, 2017 19:46 Hi, thanks for replying. Yes after commenting i figured out i could use parameters in the inside method. It worked but you need to use root user, if you use node user, it will not have permissions to write in the workspace dir. 0 Please sign in to leave a comment.
Comments
3 comments
This doesn't work, as the shell step would run outside of the docker image as it is said in https://go.cloudbees.com/docs/cloudbees-documentation/cje-user-guide/index.html#docker-workflow-sect-run
So, if you have a jenkins with no nodejs, and would try to do a build inside the node docker image if you use this method:
you will get
But if you try to do it inside the docker image:
you would get the error described in the article:
is there a way to specify the user to docker and run something inside the image?
Hi Gabriel,
Please try the following since `inside` method supports parameters in a similar way as `withRun`
Hi, thanks for replying.
Yes after commenting i figured out i could use parameters in the inside method.
It worked but you need to use root user, if you use node user, it will not have permissions to write in the workspace dir.
Please sign in to leave a comment.