Skip to content

Commit 83b7fce

Browse files
committed
Set uid/gid in the docker container
Add DOCKER_ENCAPS_UID and DOCKER_ENCAPS_GID to manage user in the docker container Resolves: FARM-2275 Change-Id: I2c06024d0a0c188ce0f84f90d3572b6becdbb9dd
1 parent fb190a8 commit 83b7fce

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

encaps

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ DOCKER_ENCAPS_SHELL=${DOCKER_ENCAPS_SHELL:-"/bin/sh"}
77
DOCKER_ENCAPS_ACTUAL_SHELL=${DOCKER_ENCAPS_ACTUAL_SHELL:-"/bin/sh"}
88
DOCKER_ENCAPS_NET=${DOCKER_ENCAPS_NET:-'--net=host'}
99
DOCKER_ENCAPS_ETC_PATH=${DOCKER_ENCAPS_ETC_PATH:-'/etc/encaps.d'}
10+
DOCKER_ENCAPS_UID=${DOCKER_ENCAPS_UID:-$(id -u)}
11+
DOCKER_ENCAPS_GID=${DOCKER_ENCAPS_GID:-$(id -g)}
1012

1113
if [ -z "$DOCKER_ENCAPS_NAME" ]; then
1214
if [ -z "$BUILD_TAG" ]; then
@@ -17,14 +19,6 @@ if [ -z "$DOCKER_ENCAPS_NAME" ]; then
1719
DOCKER_ENCAPS_NAME=$(echo "$BUILD_TAG" | sed 's/[^a-zA-Z0-9_.-]/_/g')
1820
fi
1921

20-
if [ -z "$UID" ]; then
21-
UID=$(id -u)
22-
fi
23-
24-
if [ -z "$GID" ]; then
25-
GID=$(id -g)
26-
fi
27-
2822
# Spawn container
2923
if ! docker inspect --type=container "$DOCKER_ENCAPS_NAME" > /dev/null 2>&1; then
3024

@@ -63,7 +57,7 @@ if ! docker inspect --type=container "$DOCKER_ENCAPS_NAME" > /dev/null 2>&1; the
6357
docker run \
6458
--detach \
6559
--name "$DOCKER_ENCAPS_NAME" \
66-
--user "$UID:$GID" \
60+
--user "$DOCKER_ENCAPS_UID:$DOCKER_ENCAPS_GID" \
6761
--volume "$PWD:$PWD" \
6862
--workdir "$PWD" \
6963
--init \

0 commit comments

Comments
 (0)