-
New Feature
-
Resolution: Unresolved
-
Minor
-
None
Hi
It would be good if we can run docker commands with sudo mode. Currently the plugin does not allow to run docker commands with 'sudo'. This is needed where Jenkins is run as a docker container with mounted docker socket of the host machine (not docker in docker case which is not recommended).
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)...