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:

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 -

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
For more options, visit