Skip to content

Commit a83c035

Browse files
committed
Skip --interactive --tty in detached mode for DinD compatibility
Non-root containers (USER hived, UID 1000) crash immediately in DinD when --tty is passed because devpts may not be accessible. Since --tty is meaningless for detached containers anyway, only use it in foreground (interactive) mode.
1 parent 7286153 commit a83c035

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

scripts/run_hived_img.sh

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ CONTAINER_NAME=instance
4040
IMAGE_NAME=
4141
HIVED_DATADIR=
4242
HIVED_SHM_FILE_DIR=
43+
DETACH_MODE=0
4344

4445
HTTP_ENDPOINT="0.0.0.0:8091"
4546
WS_ENDPOINT="0.0.0.0:8090"
@@ -117,6 +118,7 @@ while [ $# -gt 0 ]; do
117118

118119
--detach)
119120
add_docker_arg "--detach"
121+
DETACH_MODE=1
120122
;;
121123

122124
--preserve-container)
@@ -214,7 +216,13 @@ fi
214216

215217
# echo "DOCKER_ARGS: ${DOCKER_ARGS[*]}"
216218

217-
# Scritps should use long options for better readability
218-
docker run --interactive --tty --name "$CONTAINER_NAME" --stop-timeout=180 "${DOCKER_ARGS[@]}" "${IMAGE_NAME}" "${CMD_ARGS[@]}"
219+
# Only use --interactive --tty for foreground mode. In detached mode (DinD CI),
220+
# --tty can cause non-root containers to fail when devpts isn't accessible.
221+
TTY_ARGS=()
222+
if [ ${DETACH_MODE} -eq 0 ]; then
223+
TTY_ARGS+=(--interactive --tty)
224+
fi
225+
226+
docker run "${TTY_ARGS[@]}" --name "$CONTAINER_NAME" --stop-timeout=180 "${DOCKER_ARGS[@]}" "${IMAGE_NAME}" "${CMD_ARGS[@]}"
219227

220228

0 commit comments

Comments
 (0)