This is an automated email from the ASF dual-hosted git repository.
aajisaka pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/hadoop.git
The following commit(s) were added to refs/heads/trunk by this push:
new 4105d51c340 HADOOP-19807. Enable cross-platform support for dev
container (#8235)
4105d51c340 is described below
commit 4105d51c34004dcdc6f1a6763407b125a5c8e75c
Author: Cheng Pan <[email protected]>
AuthorDate: Thu Feb 12 13:28:47 2026 +0800
HADOOP-19807. Enable cross-platform support for dev container (#8235)
Signed-off-by: Chris Nauroth <[email protected]>
Signed-off-by: Akira Ajisaka <[email protected]>
---
BUILDING.txt | 12 +++++++++++-
start-build-env.sh | 17 +++++++++++------
2 files changed, 22 insertions(+), 7 deletions(-)
diff --git a/BUILDING.txt b/BUILDING.txt
index 99624ec0b9c..2fee9063f37 100644
--- a/BUILDING.txt
+++ b/BUILDING.txt
@@ -29,7 +29,17 @@ This requires a recent version of docker (1.4.1 and higher
are known to work).
On Linux / Mac:
Install Docker and run this command:
- $ ./start-build-env.sh [OS platform]
+ $ [CPU_ARCH=<arch>] ./start-build-env.sh [OS platform]
+
+ - [CPU_ARCH=<arch>] One of [x86_64, amd64, aarch64, arm64].
+ Default is output of 'uname -m'. Set to 'x86_64' on arm machine
+ (e.g. Apple M1) to create an x86_64 container.
+ Note:
+ CPU arch emulation may have significant performance overhead.
+ To enable cross-platform container support, run this command first:
+ $ docker run --rm --privileged tonistiigi/binfmt --install
amd64,arm64
+ To run an x86_64 container on arm machine, use this command:
+ $ CPU_ARCH=x86_64 ./start-build-env.sh ubuntu_24
- [OS Platform] One of [rockylinux_8, debian_11, debian_12, debian_13,
ubuntu_20, ubuntu_24, windows_10].
Default is 'ubuntu_24'.
diff --git a/start-build-env.sh b/start-build-env.sh
index abc28035f8d..0d941b99113 100755
--- a/start-build-env.sh
+++ b/start-build-env.sh
@@ -25,6 +25,7 @@ OS_PLATFORM="${1:-}"
DEFAULT_OS_PLATFORM="ubuntu_24"
OS_PLATFORM_SUFFIX=""
+DOCKER_PLATFORM_ARGS=()
if [[ -n ${OS_PLATFORM} ]]; then
OS_PLATFORM_SUFFIX="_${OS_PLATFORM}"
@@ -35,9 +36,12 @@ fi
DOCKER_DIR=dev-support/docker
DOCKER_FILE="${DOCKER_DIR}/Dockerfile${OS_PLATFORM_SUFFIX}"
-CPU_ARCH=$(echo "$MACHTYPE" | cut -d- -f1)
-if [[ "$CPU_ARCH" == "aarch64" || "$CPU_ARCH" == "arm64" ]]; then
+CPU_ARCH=${CPU_ARCH:-$(uname -m)}
+if [[ "$CPU_ARCH" == "x86_64" || "$CPU_ARCH" == "amd64" ]]; then
+ DOCKER_PLATFORM_ARGS=("--platform" "linux/amd64")
+elif [[ "$CPU_ARCH" == "aarch64" || "$CPU_ARCH" == "arm64" ]]; then
DOCKER_FILE="${DOCKER_DIR}/Dockerfile${OS_PLATFORM_SUFFIX}_aarch64"
+ DOCKER_PLATFORM_ARGS=("--platform" "linux/arm64")
fi
if [ ! -e "${DOCKER_FILE}" ] ; then
@@ -45,7 +49,7 @@ if [ ! -e "${DOCKER_FILE}" ] ; then
exit 1
fi
-docker build -t hadoop-build -f $DOCKER_FILE $DOCKER_DIR
+docker build "${DOCKER_PLATFORM_ARGS[@]}" -t hadoop-build -f "${DOCKER_FILE}"
"${DOCKER_DIR}"
USER_NAME=${SUDO_USER:=$USER}
USER_ID=$(id -u "${USER_NAME}")
@@ -87,7 +91,7 @@ fi
# Set the home directory in the Docker container.
DOCKER_HOME_DIR=${DOCKER_HOME_DIR:-/home/${USER_NAME}}
-docker build -t "hadoop-build${OS_PLATFORM_SUFFIX}-${USER_ID}" -
<<UserSpecificDocker
+docker build "${DOCKER_PLATFORM_ARGS[@]}" -t
"hadoop-build${OS_PLATFORM_SUFFIX}-${USER_ID}" - <<UserSpecificDocker
FROM hadoop-build
RUN rm -f /var/log/faillog /var/log/lastlog
RUN userdel -r \$(getent passwd ${USER_ID} | cut -d: -f1) 2>/dev/null || :
@@ -98,7 +102,7 @@ ENV HOME="${DOCKER_HOME_DIR}"
UserSpecificDocker
-#If this env varible is empty, docker will be started
+# If this env variable is empty, docker will be started
# in non interactive mode
DOCKER_INTERACTIVE_RUN=${DOCKER_INTERACTIVE_RUN-"-i -t"}
@@ -106,7 +110,8 @@ DOCKER_INTERACTIVE_RUN=${DOCKER_INTERACTIVE_RUN-"-i -t"}
# within the container and use the result on your normal
# system. And this also is a significant speedup in subsequent
# builds because the dependencies are downloaded only once.
-docker run --rm=true $DOCKER_INTERACTIVE_RUN \
+# shellcheck disable=SC2086
+docker run "${DOCKER_PLATFORM_ARGS[@]}" --rm=true ${DOCKER_INTERACTIVE_RUN} \
-v "${PWD}:${DOCKER_HOME_DIR}/hadoop${V_OPTS:-}" \
-w "${DOCKER_HOME_DIR}/hadoop" \
-v "${HOME}/.m2:${DOCKER_HOME_DIR}/.m2${V_OPTS:-}" \
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]