Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-35006

Allow 'sudo' in all docker commands; docker-custom-build-environment

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      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).

        Attachments

          Activity

          Hide
          aarondmarasco_vsi Aaron Marasco added a comment -

          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)...

          Show
          aarondmarasco_vsi Aaron Marasco added a comment - 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)...
          Hide
          ndeloof Nicolas De Loof added a comment -

          You also can run your agent container with --group-add docker, so it will get adequate ownership on the docker socket

          Show
          ndeloof Nicolas De Loof added a comment - You also can run your agent container with --group-add docker, so it will get adequate ownership on the docker socket

            People

            • Assignee:
              Unassigned
              Reporter:
              akhettar ayache khettar
            • Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated: