I am trying to run my docker image locally with non root privileges, looking in my jenkins file I see that when docker is invoked it is used the following. Where this passwd.fake is mounted in the docker
docker {
image 'a:b'
reuseNode true
args '-v $WORKSPACE/passwd.fake:/etc/passwd'
}
Tracing the args command I found this one
steps{
sh 'echo xxx:x:$(id -u):$(id -g)::${WORKSPACE}:/bin/sh > passwd.fake'
...
}
What does this passwd.fake contains and why is it needed? In case I want to run my docker locally what command should I use? Trying this
hostUid=$(id -u jj)
hostGid=$(id -g jj)
cat passwd.fake
echo "$hostUid:$hostGid::$WORKSPACE:/bin/sh">$WORKSPACE/passwd.fake
docker run -u $hostUid:$hostGid -v "$WORKSPACEpasswd.fake:/etc/passwd"
generates this error
error 29-Mar-2024 14:46:51 /bin/run.sh: 57: cannot create //.bashrc: Permission denied
error 29-Mar-2024 14:46:51 /bin/run.sh: 57: cannot create //.bashrc: Permission denied
error 29-Mar-2024 14:46:51 sudo: you do not exist in the passwd database
error 29-Mar-2024 14:46:51 sudo: you do not exist in the passwd database
thanks in advance!