Skip to content

Make fails when user/group ARGS are passed to shell as "0" instead of "1000" #3

@rckoepke

Description

@rckoepke

See a very poor fix, but working fix diff here:

rckoepke@1d1b89d

Hardcoding user and group ARGS into the shell commands fixed an issue I was having:

When passing ${user_name}:${group_name}, etc etc, the shell was reading all the args as "0" instead of 1000 etc. This caused the make to fail.

Example 1 of failure when RUN groupadd -g ${group_id} ${group_name} was parsed as RUN groupadd -g 0 ${group_name}:

Step 8/27 : ARG group_id=1000
---> Using cache
---> 4e5b9a63b30e
Step 9/27 : RUN groupadd -g ${group_id} ${group_name}
---> Running in 30201b6ab1bb
groupadd: GID '0' already exists
The command '/bin/sh -c groupadd -g ${group_id} ${group_name}' returned a non-zero code: 4
Makefile:11: recipe for target 'docker-build' failed
make: *** [docker-build] Error 4

Example 1 of failure after hardcoding only groupadd, now RUN useradd -u ${user_id} -g ${group_id} -d /home/${user_name} --create-home --shell /bin/bash ${user_name} was parsed as RUN useradd -u 0 -g ${group_id} -d /home/${user_name} --create-home --shell /bin/bash ${user_name}:

Step 8/27 : ARG group_id=1000
---> Using cache
---> 4e5b9a63b30e
Step 9/27 : RUN groupadd -g 1000 ubuntu
---> Running in 35d12c8401c4
Removing intermediate container 35d12c8401c4
---> 57185d9d33e8
Step 10/27 : RUN useradd -u ${user_id} -g ${group_id} -d /home/${user_name} --create-home --shell /bin/bash ${user_name}
---> Running in 7d09306b8138
useradd: UID 0 is not unique
The command '/bin/sh -c useradd -u ${user_id} -g ${group_id} -d /home/${user_name} --create-home --shell /bin/bash ${user_name}' returned a non-zero code: 4
Makefile:11: recipe for target 'docker-build' failed
make: *** [docker-build] Error 4

I did perform:

sudo groupadd docker
and
sudo usermod -aG docker $USER
and restarted before making docker-build.

Verification of that step:

rckoepke@rk-DLC1804:~/DeepLabCut-Docker$ groups
rckoepke adm cdrom sudo dip plugdev lpadmin sambashare docker
rckoepke@rk-DLC1804:~/DeepLabCut-Docker$ groups rckoepke
rckoepke : rckoepke adm cdrom sudo dip plugdev lpadmin sambashare docker
rckoepke@rk-DLC1804:~/DeepLabCut-Docker$ id rckoepke
uid=1000(rckoepke) gid=1000(rckoepke) groups=1000(rckoepke),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),116(lpadmin),126(sambashare),999(docker)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions