Skip to content

Commit f4a4242

Browse files
committed
Fix uid not unique error when using root
Signed-off-by: Woa <[email protected]>
1 parent d81a192 commit f4a4242

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

docker-build.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,12 @@ createPersistentDockerDataVolume()
4141
# shellcheck disable=SC2154
4242
echo "Removing old volumes and containers"
4343
# shellcheck disable=SC2046
44-
${BUILD_CONFIG[DOCKER]} rm -f $(${BUILD_CONFIG[DOCKER]} ps -a --no-trunc -q -f volume="${BUILD_CONFIG[DOCKER_SOURCE_VOLUME_NAME]}") || true
44+
local old_containers=$(${BUILD_CONFIG[DOCKER]} ps -a --no-trunc -q -f volume="${BUILD_CONFIG[DOCKER_SOURCE_VOLUME_NAME]}")
45+
if [[ ${old_containers} != "" ]]; then
46+
${BUILD_CONFIG[DOCKER]} rm -f $(old_containers) || true
47+
else
48+
echo "No old container was found"
49+
fi
4550
${BUILD_CONFIG[DOCKER]} volume rm -f "${BUILD_CONFIG[DOCKER_SOURCE_VOLUME_NAME]}" || true
4651

4752
# shellcheck disable=SC2154

docker/dockerfile-generator.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ printUserCreate(){
324324
echo "
325325
ARG HostUID
326326
ENV HostUID=\$HostUID
327-
RUN useradd -u \$HostUID -ms /bin/bash build
327+
RUN useradd -o -u \$HostUID -ms /bin/bash build
328328
WORKDIR /openjdk/build
329329
RUN chown -R build /openjdk/
330330
USER build" >> "$DOCKERFILE_PATH"

0 commit comments

Comments
 (0)