andyneff / dockmock

Creating rpms in repeatable docker environments, automatically, and with dependency support
MIT License
0 stars 0 forks source link

UID/GID exists bug #7

Open andyneff opened 8 years ago

andyneff commented 8 years ago

If the desired uid/gid already exists in the docker image, it doesn't work

2015-12-13 23:17:19,201 : DEBUG - Step 6 : RUN groupadd -g 50 dev &&     useradd -u 1000 -g 50 dev &&     echo "dev ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers &&     sed -i '/requiretty/d' /etc/sudoers
&&     mkdir -p ~dev/rpmbuild/{SPECS,BUILD,BUILDROOT,SPECS,SOURCES,RPMS,SRPMS}
2015-12-13 23:17:19,384 : DEBUG -  ---> Running in 14f068572c10
2015-12-13 23:17:19,744 : DEBUG - ←[91mgroupadd: GID '50' already exists

GID is easily fixed by allowing it to fail, UID is not

andyneff commented 8 years ago

I see 3 possible solutions to this

  1. If the UID exist, then change the username to dev. This is the easiest, but there's a SMALL chance it'll break the docker image if that username is NEEDED.
  2. If it exists, manually create an additional entry in the passwd file duplicating the UID under a different username... I've done this before (by accident) and it actually seems to work. Unknown side effects
  3. Change the USER dev line in the docker file into a a docker+ variable. This will be far more complicated, because the docker image will need to be run before that user creation step, check for the UID, use that result to change the username... This will lead to a two phase docker creation process that I do not look forward to.
  4. Something better?