Getting "sudo: unknown uid xxx: who are you?" In Jenkins pipeline thats building its own container Getting "sudo: unknown uid xxx: who are you?" In Jenkins pipeline thats building its own container jenkins jenkins

Getting "sudo: unknown uid xxx: who are you?" In Jenkins pipeline thats building its own container


The UID xxx that jenkins was not able to recognize was jenkin's user id inside server/ubuntu system that was running jenkins and the pipeline was being run inside docker container where jenkins id was different. Hence, jenkins server id wasn't getting recognized inside docker.

So, here's what worked for me:Changing from: JENKINS_USER=$NAME to: JENKINS_USER="root"in /etc/default/jenkins

This can be verified from pipeline's console output that says right at the beginning:$ docker run -t -d -u 0:0 ....

this 0:0 indicates its running as root user. When I was facing this issue, I had xxx:yyy instead of 0:0.This xxx:yyy was the same as present for jenkins user in /etc/passwd inside server/ubuntu system running jenkins.

Hope this helps!!


Inside the container you need to have passwd, group and sudoers files that have the jenkins user. The jenkins user needs to be setup to have password-less sudo (%jenkins ALL=(ALL) NOPASSWD: ALL).

One way is to setup the host's jenkins account properly, then run docker as:

docker run -v /etc/group:/etc/group:ro -v /etc/passwd:/etc/passwd:ro -v /etc/shadow:/etc/shadow:ro -v /etc/sudoers.d:/etc/sudoers.d:ro ...