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

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

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

Mike S
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:

https://gist.github.com/bsodmike/7033ffeab2383599bb38a2bcf263aba4

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!

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/a1e04054-529e-48e3-ad17-85a082c72dfb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.