Skip to content

Instantly share code, notes, and snippets.

@amf3
Last active December 9, 2022 00:39
Show Gist options
  • Select an option

  • Save amf3/0fbc79350ef5e438e835a34618723116 to your computer and use it in GitHub Desktop.

Select an option

Save amf3/0fbc79350ef5e438e835a34618723116 to your computer and use it in GitHub Desktop.
Build Hadoop with Rootless Podman

This is a quick note on what to modify when building Hadoop with rootless podman.

  • First, ensure the following directories exist on the host OS. If not then create them with mkdir

    • "${HOME}"/.m2
    • "${HOME}"/.gnupg
  • This is what the current commit ID is for HEAD. Perhaps this will be fixed by the time you read it.

$ git rev-parse HEAD
ee7d1787cd2cdfea936425dcf88e750827ff5c1b

The install-protobuf.sh change is needed as the container is rootless & does not have the permissions to set the UID on the extracted protobuf files.

The start-build-env.sh changes show how to compile with a rootless container while allowing access to the hadoop, $HOME/.m2 and $HOME/.gnupg directories.

This is the unified diff.

$ git diff -u
diff --git a/dev-support/docker/pkg-resolver/install-protobuf.sh b/dev-support/docker/pkg-resolver/install-protobuf.sh
index 7303b404822..4b65e29da51 100644
--- a/dev-support/docker/pkg-resolver/install-protobuf.sh
+++ b/dev-support/docker/pkg-resolver/install-protobuf.sh
@@ -44,7 +44,7 @@ if [ "$version_to_install" == "3.7.1" ]; then
     curl -L -s -S \
       https://github.com/protocolbuffers/protobuf/releases/download/v3.7.1/protobuf-java-3.7.1.tar.gz \
       -o /opt/protobuf.tar.gz &&
-    tar xzf /opt/protobuf.tar.gz --strip-components 1 -C /opt/protobuf-src &&
+    tar xzf /opt/protobuf.tar.gz --no-same-owner --strip-components 1 -C /opt/protobuf-src &&
     cd /opt/protobuf-src &&
     ./configure --prefix=/opt/protobuf &&
     make "-j$(nproc)" &&
diff --git a/start-build-env.sh b/start-build-env.sh
index 375a027a06b..40ae6ac7500 100755
--- a/start-build-env.sh
+++ b/start-build-env.sh
@@ -87,7 +87,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 \
+V_OPTS=":Z"
+podman run --rm=true --userns=keep-id $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:-}" \
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment