Skip to content

Commit 7ad5de4

Browse files
committed
Preserve noninteractive apt settings through sudo in Docker build
1 parent 8ee4cdb commit 7ad5de4

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

docker/Dockerfile

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ FROM nvidia/cuda:12.9.2-devel-ubuntu20.04
1919

2020
ARG DEBIAN_FRONTEND=noninteractive
2121
ARG TZ=Etc/UTC
22-
ENV TZ=${TZ}
22+
ENV DEBIAN_FRONTEND=${DEBIAN_FRONTEND} \
23+
DEBCONF_NONINTERACTIVE_SEEN=true \
24+
TZ=${TZ}
2325

2426
# Make long ROS / Ubuntu apt transactions less fragile in Docker builds.
2527
# This helps with transient mirror/network errors such as failed downloads
@@ -62,11 +64,15 @@ ENV LANG=en_US.UTF-8 \
6264
LC_ALL=en_US.UTF-8
6365

6466
# Create the install user with passwordless sudo. The installer uses
65-
# sudo for system-level steps (apt, rosdep init); NOPASSWD keeps it
66-
# non-interactive during the image build.
67+
# sudo for system-level steps (apt, rosdep init). Preserve the noninteractive
68+
# debconf environment through sudo so package configuration cannot block
69+
# Docker builds with prompts such as keyboard layout selection.
6770
RUN groupadd --gid ${USER_GID} ${USERNAME} \
6871
&& useradd --uid ${USER_UID} --gid ${USER_GID} -m -s /bin/bash ${USERNAME} \
69-
&& echo "${USERNAME} ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/${USERNAME} \
72+
&& { \
73+
echo "${USERNAME} ALL=(ALL) NOPASSWD:ALL"; \
74+
echo 'Defaults env_keep += "DEBIAN_FRONTEND DEBCONF_NONINTERACTIVE_SEEN TZ"'; \
75+
} > /etc/sudoers.d/${USERNAME} \
7076
&& chmod 0440 /etc/sudoers.d/${USERNAME}
7177

7278
USER ${USERNAME}

0 commit comments

Comments
 (0)