Jenkins user is no member of docker group

21 views
Skip to first unread message

Chris Dams

unread,
Apr 29, 2021, 8:23:58 AM4/29/21
to Jenkins Users
Dear all,

I have a jenkins slave running on linux (jenkins version 2.249.2). The strange thing is that when I log into this slave via ssh using the jenkins account I can see (using the groups command) that 'jenkins' is member of some groups, including the docker group. However, when I put an "sh 'groups' "line in the Jenkinsfile this user jenkins is not a member of any group besides the 'jenkins' group. This is a problem because it means that I cannot do a docker build from this jenkins file. Some time ago this used to be work but it stopped working for no apparent reason.

Do any of you have any idea what to do about this?

Thanks in advance!
Chris

Björn Pedersen

unread,
Apr 30, 2021, 3:31:11 AM4/30/21
to Jenkins Users
Has the slave been restarted after setting the groups? On unix the groups are only refreshed on login.

Chris Dams

unread,
Apr 30, 2021, 3:40:45 AM4/30/21
to Jenkins Users
Hello All,

I found out what the problem was. It turns out that in the Jenkinsfile the agent was 'dockerfile' so it actually was
running docker inside docker. The outer docker invocation is where it lost the groups. Adding a simple -u option
with the correct groups to the outer docker arguments solved it the problem.

Have a nice day,
Chris

Reply all
Reply to author
Forward
0 new messages