Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dumb-init Binary Hardcoded for x86 Architecture in Dockerfile, Fails on ARM Systems #123

Open
morbut-island opened this issue Nov 18, 2024 · 3 comments

Comments

@morbut-island
Copy link

Hello,

I encountered an issue when running a container built from the provided Dockerfile on ARM-based systems (e.g., Apple M1/M2, Raspberry Pi, etc.). The dumb-init binary, downloaded during the build process, is hardcoded for the x86 architecture. As a result, the container fails to run on ARM platforms due to an architecture mismatch.

Steps to Reproduce:
1. Build the Dockerfile
2. Attempt to run the resulting Docker image on an ARM-based system.
3. The container fails to start with the error: /bin/sh: /usr/local/bin/dumb-init: cannot execute binary file

A fix will would allow the image to run successfully on both x86 and ARM platforms, increasing compatibility.

@morbut-island
Copy link
Author

morbut-island commented Nov 20, 2024

Maybe adding something like this to the dockerfile:

ARG TARGETARCH
# Assign platform-specific suffix
RUN case "$TARGETARCH" in \
    "amd64") ARCH_SUFFIX="amd64" ;; \
    "arm64") ARCH_SUFFIX="aarch64" ;; \
    "arm") ARCH_SUFFIX="armv7" ;; \
    *) echo "Unsupported architecture: $TARGETARCH" && exit 1 ;; \
    esac && \
    echo "Architecture suffix set to: ${ARCH_SUFFIX}"

RUN yum install sudo -y && \
    yum install shadow-utils -y && \
    amazon-linux-extras install epel -y && \
    yum install procps-ng tar wget -y && \
    wget -O /usr/local/bin/dumb-init https://github.com/Yelp/dumb-init/releases/download/v1.2.5/dumb-init_1.2.5_${ARCH_SUFFIX} && \
    chmod +x /usr/local/bin/dumb-init && \
    groupadd --system --gid 101 ds && \
    useradd --system -g ds --no-create-home --shell /sbin/nologin --uid 101 ds && \
    rm -f /var/log/*log

TARGETARCH is available due to the use of docker buildx

@danilapog

@danilapog
Copy link
Contributor

@morbut-island Hey!

Thanks for your PR.

One thing, maybe I'm wrong, but the variable ${ARCH_SUFFIX} will not be accessible between RUN

In addition, the #124 looks simpler. In any case, thanks for pointing out the problem!

@morbut-island
Copy link
Author

Hey @danilapog!
I agree, Sacha's PR (#124) is much simpler.
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants