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!