nodejs-microservice
nodejs-microservice copied to clipboard
`ibmcloud dev build` fails with `exit status 4` as the user UID 1000 already exists in *node:8-stretch*
Going through the tutorial in README ibmcloud dev build fails with exit status 4 when Creating image [..] based on Dockerfile-tools because running docker image build --file Dockerfile-tools --tag nodejsmicroservicewithexpressjserp-express-tools --rm --pull --build-arg bx_dev_userid=1000 --build-arg bx_dev_user=david . fails with useradd: UID 1000 is not unique.
It seems a user with ID 1000 already exists.
Hi, which tutorial were you reading? Can you provide the link?
Readme here see https://github.com/IBM/nodejs-microservice#ibm-cloud-developer-tools
Looking into this
Thanks!
@davidpodhola I was not able to reproduce this. Can you tell me a bit more about your environment if there's something different or unique? Can you execute the build with trace? ibmcloud dev build --trace
So we encountered this with one of our clients today. The root cause ended up being that the build uses the local user and its UID as $bx_dev_user and $bx_dev_userid. Historically the linux kernel UID's started at 500, so the default user on a system had UID of 500. The newest kernels now start at 1000, so the default user has a UID of 1000, colliding with this implementation. The simple solution was to create a new user to do the work since it didn't have a UID of 1000. But this will probably be encountered more frequently now that kernels are shipping with this change
You can reproduce by doing the following:
sudo useradd -u 1000 ibmcf
su - ibmcf
bx login --sso
bx target --cf
bx dev build
satyamtest1-express-tools --rm --pull --build-arg bx_dev_userid=1000
--build-arg bx_dev_user=rfid .
Waiting for Docker image to build
Sending build context to Docker daemon 399.9kB
Step 1/18 : FROM node:8-stretch
8-stretch: Pulling from library/node
Digest: sha256:beaec0dc2f371e6449bc2154a253563e8e4b6910bebd74c28f44ba22c4e9ea31
Status: Image is up to date for node:8-stretch
---> 52a261fa5e4b
Step 2/18 : ENV PORT 3000
---> Using cache
---> 3eeca7964503
Step 3/18 : ENV NODE_HEAPDUMP_OPTIONS nosignal
---> Using cache
---> fc859135eb31
Step 4/18 : EXPOSE 3000
---> Using cache
---> e60e1bb0514b
Step 5/18 : EXPOSE 9229
---> Using cache
---> c6fcef9f5d91
Step 6/18 : WORKDIR "/app"
---> Using cache
---> 2769e5d862b8
Step 7/18 : COPY . /app
---> Using cache
---> 9f241632dae8
Step 8/18 : COPY run-dev /bin
---> Using cache
---> e631bfc21e44
Step 9/18 : COPY run-debug /bin
---> Using cache
---> 57e9e9065724
Step 10/18 : RUN chmod 777 /bin/run-dev /bin/run-debug
---> Using cache
---> 4c6a79de4532
Step 11/18 : RUN apt-get update
---> Using cache
---> e38d57abc0f9
Step 12/18 : RUN apt-get install bc
---> Using cache
---> 149923ac8778
Step 13/18 : CMD ["/bin/bash"]
---> Using cache
---> 5b408bc37f96
Step 14/18 : ARG bx_dev_user=root
---> Using cache
---> 93dd225a187f
Step 15/18 : ARG bx_dev_userid=1000
---> Using cache
---> 4a9cf9867758
Step 16/18 : RUN BX_DEV_USER=$bx_dev_user
---> Using cache
---> d510087e1bcc
Step 17/18 : RUN BX_DEV_USERID=$bx_dev_userid
---> Using cache
---> 338b0091f827
Step 18/18 : RUN if [ "$bx_dev_user" != root ]; then useradd -ms /bin/bash -u $bx_dev_userid $bx_dev_user; fi
---> Running in 1c70193dd447
useradd: UID 1000 is not unique
The command '/bin/sh -c if [ "$bx_dev_user" != root ]; then useradd -ms /bin/bash -u $bx_dev_userid $bx_dev_user; fi' returned a non-zero code: 4
FAILED
An error exit status 4 was encountered while building the Docker
image.
exit status 4```
Thanks @btl5037 , that is exactly what is happening here. My user david has UID 1000. @gee4vee if you are still interested in emulating my situation, I think I can prepare scripts using Vagrant to have the exact same setup as I am having (Linux Ubuntu 18.04.3 LTS Bionic).