This is a good question for the users list rather than the developers
list.  The developers list is generally used for topics related to the
development of Jenkins and the plugins which run on Jenkins.  Your question
is more about using Jenkins than developing something that will extend or
enhance Jenkins.

In general, you don't want to run a Jenkinsfile as root.  That's granting
far more permission to the Jenkinsfile than should be granted and places
the machine at risk of damage from innocent user mistakes.  It is less
dangerous to allow the agent user to run docker than to allow the agent
user to use sudo to become root.

On Thu, Mar 21, 2019 at 1:45 PM Parichay Barpanda <
[email protected]> wrote:

> I am running a plugin on my local machine with this command:
>
> mvn hpi:run
>
> My repository contains a Jenkinsfile which runs a docker image to build a
> latex document.
>
> Jenkinsfile looks like:
>
> pipeline {
>    agent none
>    stages {
>       stage('Build') {
>          agent {
>             docker {
>                image 'blang/latex:ubuntu'
>             }
>          }
>          steps {
>              sh 'xelatex sample.tex'
>          }
>       }
>    }
> }
>
> Since the Jenkins instance is running on my local machine and in my local
> machine docker is installed for the root user only so I need a way to
> execute the Jenkinsfile with sudo permission.
>
> I recieve an error like this:
>
> + docker pull blang/latex:ubuntu
> Got permission denied while trying to connect to the Docker daemon socket
> at unix:///var/run/docker.sock: Post 
> http://%2Fvar%2Frun%2Fdocker.sock/v1.39/images/create?fromImage=blang%2Flatex&tag=ubuntu:
> dial unix /var/run/docker.sock: connect: permission denied
> script returned exit code 1
>
> Can anyone suggest a way how I can run docker with root permission inside
> the Jenkins pipeline?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Jenkins Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/jenkinsci-dev/b0106f8f-fa09-4dc7-98a3-f7bdff9f0d6f%40googlegroups.com
> <https://groups.google.com/d/msgid/jenkinsci-dev/b0106f8f-fa09-4dc7-98a3-f7bdff9f0d6f%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Thanks!
Mark Waite

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-dev/CAO49JtH8Dk9YO_CZvSqL-b8D4MLa%3DvZ1oiHJejq2%2BHUbW1YaAQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to