temurin-build icon indicating copy to clipboard operation
temurin-build copied to clipboard

Fix uid not unique error when using root

Open ESWZY opened this issue 1 year ago • 2 comments

I was using Ubuntu 22.04 to build JDK17, but got error like this:

root@xxxxx:~/Projects/temurin-build# ./makejdk-any-platform.sh --docker --clean-docker-build --build-variant hotspot jdk17u
Starting ./makejdk-any-platform.sh to configure, build (Adoptium)OpenJDK binary
Parsing opt: --docker
Possible opt arg: --clean-docker-build
Parsing opt: --clean-docker-build
Possible opt arg: --build-variant
Parsing opt: --build-variant
Possible opt arg: hotspot
Working dir is ./build/
[debug] COPY_MACOSX_FREE_FONT_LIB_FOR_JDK_FLAG=false
[debug] COPY_MACOSX_FREE_FONT_LIB_FOR_JRE_FLAG=false
JDK Image folder name: jdk
JRE Image folder name: jre
Skipping setting boot JDK on docker host machine
Removing Dockerfile* from docker/jdk17/x86_64/ubuntu
Dockerfile created at docker/jdk17/x86_64/ubuntu/Dockerfile
Using Docker to build the JDK
Removing old volumes and containers
"docker rm" requires at least 1 argument.
See 'docker rm --help'.

Usage:  docker rm [OPTIONS] CONTAINER [CONTAINER...]

Remove one or more containers
openjdk-source-volume-jdk17u-hotspot
Creating tmp container
openjdk-source-volume-jdk17u-hotspot
No docker container for reuse was found, so creating 'openjdk_container' 
Building docker container
[+] Building 0.8s (16/18)                                                                                                                                                                                                                   
 => [internal] load build definition from Dockerfile                                                                                                                                                                                   0.0s
 => => transferring dockerfile: 2.65kB                                                                                                                                                                                                 0.0s
 => [internal] load .dockerignore                                                                                                                                                                                                      0.0s
 => => transferring context: 57B                                                                                                                                                                                                       0.0s
 => [internal] load metadata for docker.io/library/ubuntu:18.04                                                                                                                                                                        0.6s
 => [ 1/14] FROM docker.io/library/ubuntu:18.04@sha256:152dc042452c496007f07ca9127571cb9c29697f42acbfad72324b2bb2e43c98                                                                                                                0.0s
 => [internal] load build context                                                                                                                                                                                                      0.0s
 => => transferring context: 4.11kB                                                                                                                                                                                                    0.0s
 => CACHED [ 2/14] RUN apt-get update   && apt-get install -qq -u --no-install-recommends     software-properties-common     dirmngr     gpg-agent     coreutils   && apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-ke  0.0s
 => CACHED [ 3/14] RUN sh -c "mkdir -p /usr/lib/jvm/jdk16 && wget 'https://api.adoptium.net/v3/binary/latest/16/ga/linux/x64/jdk/hotspot/normal/adoptium?project=jdk' -O - | tar xzf - -C /usr/lib/jvm/jdk16 --strip-components=1"     0.0s
 => CACHED [ 4/14] RUN ln -sf /usr/lib/jvm/jdk16/bin/java /usr/bin/java                                                                                                                                                                0.0s
 => CACHED [ 5/14] RUN ln -sf /usr/lib/jvm/jdk16/bin/javac /usr/bin/javac                                                                                                                                                              0.0s
 => CACHED [ 6/14] RUN ln -sf /usr/lib/jvm/jdk16/bin/keytool /usr/bin/keytool                                                                                                                                                          0.0s
 => CACHED [ 7/14] RUN sh -c "mkdir -p /usr/lib/jvm/jdk8 && wget 'https://api.adoptium.net/v3/binary/latest/8/ga/linux/x64/jdk/hotspot/normal/adoptium?project=jdk' -O - | tar xzf - -C /usr/lib/jvm/jdk8 --strip-components=1"        0.0s
 => CACHED [ 8/14] RUN git clone https://github.com/adoptium/ci-jenkins-pipelines /openjdk/pipelines                                                                                                                                   0.0s
 => CACHED [ 9/14] COPY sbin /openjdk/sbin                                                                                                                                                                                             0.0s
 => CACHED [10/14] COPY security /openjdk/security                                                                                                                                                                                     0.0s
 => CACHED [11/14] COPY workspace/config /openjdk/config                                                                                                                                                                               0.0s
 => ERROR [12/14] RUN useradd -u 0 -ms /bin/bash build                                                                                                                                                                                 0.2s
------
 > [12/14] RUN useradd -u 0 -ms /bin/bash build:
#0 0.181 useradd: UID 0 is not unique
------
Dockerfile:79
--------------------
  77 |     ARG HostUID
  78 |     ENV HostUID=$HostUID
  79 | >>> RUN useradd -u $HostUID -ms /bin/bash build
  80 |     WORKDIR /openjdk/build
  81 |     RUN chown -R build /openjdk/
--------------------
ERROR: failed to solve: process "/bin/sh -c useradd -u $HostUID -ms /bin/bash build" did not complete successfully: exit code: 4

According to this error #0 0.181 useradd: UID 0 is not unique, I went to find the relevant parameters of useradd, and tried to pass the parameter -o --non-unique. Finally, the problem solved.

After this change:

root@xxxxx:~/Projects/temurin-build# ./makejdk-any-platform.sh --docker --clean-docker-build --build-variant hotspot jdk17u
Starting ./makejdk-any-platform.sh to configure, build (Adoptium)OpenJDK binary
Parsing opt: --docker
Possible opt arg: --clean-docker-build
Parsing opt: --clean-docker-build
Possible opt arg: --build-variant
Parsing opt: --build-variant
Possible opt arg: hotspot
Working dir is ./build/
[debug] COPY_MACOSX_FREE_FONT_LIB_FOR_JDK_FLAG=false
[debug] COPY_MACOSX_FREE_FONT_LIB_FOR_JRE_FLAG=false
JDK Image folder name: jdk
JRE Image folder name: jre
Skipping setting boot JDK on docker host machine
Removing Dockerfile* from docker/jdk17/x86_64/ubuntu
Dockerfile created at docker/jdk17/x86_64/ubuntu/Dockerfile
Using Docker to build the JDK
Removing old volumes and containers
No old container was found
openjdk-source-volume-jdk17u-hotspot
Creating tmp container
openjdk-source-volume-jdk17u-hotspot
No docker container for reuse was found, so creating 'openjdk_container' 
Building docker container
[+] Building 1.2s (20/20) FINISHED                                                                                                                                                                                                          
 => [internal] load build definition from Dockerfile                                                                                                                                                                                   0.0s
 => => transferring dockerfile: 2.66kB                                                                                                                                                                                                 0.0s
 => [internal] load .dockerignore                                                                                                                                                                                                      0.0s
 => => transferring context: 57B                                                                                                                                                                                                       0.0s
 => [internal] load metadata for docker.io/library/ubuntu:18.04                                                                                                                                                                        1.1s
 => [auth] library/ubuntu:pull token for registry-1.docker.io                                                                                                                                                                          0.0s
 => [ 1/14] FROM docker.io/library/ubuntu:18.04@sha256:152dc042452c496007f07ca9127571cb9c29697f42acbfad72324b2bb2e43c98                                                                                                                0.0s
 => [internal] load build context                                                                                                                                                                                                      0.0s
 => => transferring context: 4.11kB                                                                                                                                                                                                    0.0s
 => CACHED [ 2/14] RUN apt-get update   && apt-get install -qq -u --no-install-recommends     software-properties-common     dirmngr     gpg-agent     coreutils   && apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-ke  0.0s
 => CACHED [ 3/14] RUN sh -c "mkdir -p /usr/lib/jvm/jdk16 && wget 'https://api.adoptium.net/v3/binary/latest/16/ga/linux/x64/jdk/hotspot/normal/adoptium?project=jdk' -O - | tar xzf - -C /usr/lib/jvm/jdk16 --strip-components=1"     0.0s
 => CACHED [ 4/14] RUN ln -sf /usr/lib/jvm/jdk16/bin/java /usr/bin/java                                                                                                                                                                0.0s
 => CACHED [ 5/14] RUN ln -sf /usr/lib/jvm/jdk16/bin/javac /usr/bin/javac                                                                                                                                                              0.0s
 => CACHED [ 6/14] RUN ln -sf /usr/lib/jvm/jdk16/bin/keytool /usr/bin/keytool                                                                                                                                                          0.0s
 => CACHED [ 7/14] RUN sh -c "mkdir -p /usr/lib/jvm/jdk8 && wget 'https://api.adoptium.net/v3/binary/latest/8/ga/linux/x64/jdk/hotspot/normal/adoptium?project=jdk' -O - | tar xzf - -C /usr/lib/jvm/jdk8 --strip-components=1"        0.0s
 => CACHED [ 8/14] RUN git clone https://github.com/adoptium/ci-jenkins-pipelines /openjdk/pipelines                                                                                                                                   0.0s
 => CACHED [ 9/14] COPY sbin /openjdk/sbin                                                                                                                                                                                             0.0s
 => CACHED [10/14] COPY security /openjdk/security                                                                                                                                                                                     0.0s
 => CACHED [11/14] COPY workspace/config /openjdk/config                                                                                                                                                                               0.0s
 => CACHED [12/14] RUN useradd -o -u 0 -ms /bin/bash build                                                                                                                                                                             0.0s
 => CACHED [13/14] WORKDIR /openjdk/build                                                                                                                                                                                              0.0s
 => CACHED [14/14] RUN chown -R build /openjdk/                                                                                                                                                                                        0.0s
 => exporting to image                                                                                                                                                                                                                 0.0s
 => => exporting layers                                                                                                                                                                                                                0.0s
 => => writing image sha256:d605c13e8a4f1e8d6691bb6a7124abadbd1385804f2a4abfb42d8acf0b239666                                                                                                                                           0.0s
 => => naming to docker.io/library/openjdk_container                                                                                                                                                                                   0.0s
# ============================
# OPENJDK BUILD CONFIGURATION:
# ============================
BUILD_CONFIG[ADOPT_PATCHES]="true"
BUILD_CONFIG[ASSEMBLE_EXPLODED_IMAGE]="false"
BUILD_CONFIG[BRANCH]="master"

...

OpenJDK JDK path will be jdk-17.0.8+6. JRE path will be jdk-17.0.8+6-jre
OpenJDK test image path will be jdk-17.0.8+6-test-image.
Archiving and compressing with gzip

real    0m16.632s
user    0m16.546s
sys     0m0.083s
Your archive was created as /openjdk/build/src/build/linux-x86_64-server-release/images/OpenJDK.tar.gz
Moving the artifact to location /openjdk//target//OpenJDK-testimage.tar.gz
archive done.
OpenJDK static libs path will be jdk-17.0.8+6-static-libs.
OpenJDK static libs archive file name will be OpenJDK-static-libs-glibc.tar.gz.
Archiving and compressing with gzip

real    0m5.179s
user    0m5.156s
sys     0m0.020s
Your archive was created as /openjdk/build/src/build/linux-x86_64-server-release/images/OpenJDK.tar.gz
Moving the artifact to location /openjdk//target//OpenJDK-static-libs-glibc.tar.gz
archive done.
Archiving and compressing with gzip

real    0m26.241s
user    0m25.882s
sys     0m0.353s
Your archive was created as /openjdk/build/src/build/linux-x86_64-server-release/images/OpenJDK.tar.gz
Moving the artifact to location /openjdk//target//OpenJDK-jdk.tar.gz
archive done.
build.sh : 09:51:46 : All done!
The finished image can be found in /root/Projects/temurin-build/workspace/target on the host system
Removing container jdk17-hotspot
acf3243519d2

ESWZY avatar Jul 12 '23 11:07 ESWZY

Thank you for creating a pull request! If you have not done so already, please familiarise yourself with our Contributing Guidelines and FAQ, even if you have contributed to the Adoptium project before. GitHub actions will now run a set of jobs against your PR that will lint and unit test your changes. Keep an eye out for the results from these on the latest commit you submitted. For more information, please see our testing documentation.

github-actions[bot] avatar Jul 12 '23 11:07 github-actions[bot]

this has been stale for over a year, converting to "draft", if no longer needed please close.

andrew-m-leonard avatar Apr 03 '24 13:04 andrew-m-leonard