I was able to get sudo to work with image.inside() by adding "-v /etc/sudoers:/etc/sudoers:ro" to the launch command argument of inside. This brings the host's sudoers list into the container (and that list allows jenkins to do what it needs to). That worked for CentOS 6 and 7 containers.
For my Fedora 25 container, I had to also add "-v /etc/passwd:/etc/passwd:ro" or sudo complained about not knowing who you were. When I gave that file to the CentOS containers, it could complain that the user's home directory wasn't there (no /var/lib/jenkins in the container).
Hope this helps (a year and a half later)...
I was able to get sudo to work with image.inside() by adding "-v /etc/sudoers:/etc/sudoers:ro" to the launch command argument of inside. This brings the host's sudoers list into the container (and that list allows jenkins to do what it needs to). That worked for CentOS 6 and 7 containers.
For my Fedora 25 container, I had to also add "-v /etc/passwd:/etc/passwd:ro" or sudo complained about not knowing who you were. When I gave that file to the CentOS containers, it could complain that the user's home directory wasn't there (no /var/lib/jenkins in the container).
Hope this helps (a year and a half later)...