How to solve Docker permission error when trigger by Jenkins

前端 未结 3 822
闹比i
闹比i 2020-12-16 10:46

My Jenkins is not run in Docker container, just tradional install to VPS. I got the following error when executing a simple test project. I am using Ubuntu 14, java 7, and s

相关标签:
3条回答
  • 2020-12-16 11:14

    In your VPS server terminal, do this to add your jenkins user to the docker group:

    sudo usermod -aG docker jenkins
    

    Then restart your jenkins server to refresh the group.

    Take into account any security issue that this could produce:

    Warning: The docker group grants privileges equivalent to the root user. For details on how this impacts security in your system, see Docker Daemon Attack Surface.

    Refer to the docs


    Edit (mentioned by @iger): Just make sure to restart the Jenkins from command-line (i.e. sudo service jenkins restart), but not through the rest endpoint (http:///restart)

    0 讨论(0)
  • 2020-12-16 11:22
    1. Add user to docker group as it described here.
    2. Start jenkins with this command: docker run -d -u root --restart on-failure -p "8080:8080" -p "50000:50000" -v $PWD/jenkins-data:/var/jenkins_home -v /var/run/docker.sock:/var/run/docker.sock jenkinsci/blueocean

    root user required because without it you will not be able to execute root task, example: apk update && apk install ...

    0 讨论(0)
  • 2020-12-16 11:26

    Running

    sudo usermod -aG docker jenkins
    

    and then

    sudo service jenkins restart
    

    worked perfectly for me.

    0 讨论(0)
提交回复
热议问题