Skip to content

Commit 1200473

Browse files
committed
change user in docker-in-docker
1 parent 1559d9d commit 1200473

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

src/ci/docker/run.sh

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ args="$args --privileged"
274274
# `LOCAL_USER_ID` (recognized in `src/ci/run.sh`) to ensure that files are all
275275
# read/written as the same user as the bare-metal user.
276276
if [ -f /.dockerenv ]; then
277-
echo "Dockerenv detected"
277+
echo "Dockerenv detected. We are in docker-in-docker scenario."
278278
docker create -v /checkout --name checkout alpine:3.4 /bin/true
279279
docker cp . checkout:/checkout
280280
args="$args --volumes-from checkout"
@@ -283,23 +283,23 @@ else
283283
args="$args --volume $objdir:/checkout/obj"
284284
args="$args --volume $HOME/.cargo:/cargo"
285285
args="$args --volume /tmp/toolstate:/tmp/toolstate"
286+
fi
286287

287-
id=$(id -u)
288-
if [[ "$id" != 0 && "$(docker version)" =~ Podman ]]; then
289-
# Rootless podman creates a separate user namespace, where an inner
290-
# LOCAL_USER_ID will map to a different subuid range on the host.
291-
# The "keep-id" mode maps the current UID directly into the container.
292-
echo "Running in rootless podman"
293-
args="$args --env NO_CHANGE_USER=1 --userns=keep-id"
294-
elif [[ "$id" != 0 ]]; then
295-
echo "Running in docker as non-root"
296-
args="$args --env LOCAL_USER_ID=$id"
297-
else
298-
echo "Running in docker as root. Using id 1001."
299-
# If we're running as root, we don't want to run the container as root,
300-
# so we set id `1001` instead of `0`.
301-
args="$args --env LOCAL_USER_ID=1001"
302-
fi
288+
id=$(id -u)
289+
if [[ "$id" != 0 && "$(docker version)" =~ Podman ]]; then
290+
# Rootless podman creates a separate user namespace, where an inner
291+
# LOCAL_USER_ID will map to a different subuid range on the host.
292+
# The "keep-id" mode maps the current UID directly into the container.
293+
echo "Running in rootless podman"
294+
args="$args --env NO_CHANGE_USER=1 --userns=keep-id"
295+
elif [[ "$id" != 0 ]]; then
296+
echo "Running in docker as non-root"
297+
args="$args --env LOCAL_USER_ID=$id"
298+
else
299+
echo "Running in docker as root. Using id 1001."
300+
# If we're running as root, we don't want to run the container as root,
301+
# so we set id `1001` instead of `0`.
302+
args="$args --env LOCAL_USER_ID=1001"
303303
fi
304304

305305
if [ "$dev" = "1" ]

0 commit comments

Comments
 (0)