Need to re-initialise group assignment in EC2 slave to allow Docker to work.

4 views
Skip to first unread message

Mike S

unread,
Mar 18, 2017, 6:03:30 AM3/18/17
to Jenkins Users
Hi all,

I'm testing out a pipeline build in Jenkins using the AWS EC2 plugin.  Via the plugin, a build will spin up an EC2 instance and run my init script, which you will find detailed in the Gist below:


The init script adds the `ubuntu` user to the docker group, however, at the very end of the slave spool-up, you'll notice that it only lists the 'current groups' as root.

Once the Jenkins slave-agent is installed and the Jenkinsfile of the repo being run (as part of the pipeline job), in this context I've added several sets of debugging info, which I'll summarise below, yet detailed in full in the Gist linked above:
  • Within the context of the build steps a la the Jenkinsfile, the current user is `ubuntu` with a UID of 1000
  • the `docker` group has a GID of 999 and `ubuntu` user has been added.
  • However, running `groups` shows that the current user's groups have not been assigned.
At the moment, I can only get the docker run to work from within the slave agent (whilst parsing the Jenkinsfile that is) if I disconnect and re-connect to the slave EC2 agent, simply because Jenkins does this as a new SSH connection, and logs into a new session.

I've provided further comments at the bottom of the Gist as well - https://gist.github.com/bsodmike/7033ffeab2383599bb38a2bcf263aba4#gistcomment-2030828

Appreciate any advice on how to get around this - thanks!
Reply all
Reply to author
Forward
0 new messages