We have got a docker image that is working correctly. If we run without -u argument it will login as user (and not as root).
The problem is that we want the same behaviour when we use it on jenkins but the
software is always logging as root (and there is no way to change user).
This is the script:
stage('Build image') {
dockerImage = docker.image('ramingo92/magento-cloud:latest').inside {
sh 'ls -la /home/user'
sh 'whoami'
}
Jenkins usually runs docker images as the user that is running the job.
this probably means your jenkins [agent] is somehow root.
You can specifiy args using the inside() function. Like i said, it should default to the user of the jenkins agent, but you can override it by providing more arguments.
Jenkins is running in a docker container (started by user1).
on jenkins we created an admin (user-jenkins) and if we set a param inside .inside(‘-u user2:user2’) the compilation got stuck. start running and does not finish.