Search code examples
linuxamazon-web-servicesdocker

qemu-x86_64: Could not open '/lib64/ld-linux-x86-64.so.2': No such file or directory in alpine linux on M1


I am trying to run Docker container using this https://hub.docker.com/r/gotechnies/php-5.6-alpine/dockerfile Dockerfile. After container running install aws cli using below command.

$ curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install

throwing error :

/sandbox # ./aws/install
qemu-x86_64: Could not open '/lib64/ld-linux-x86-64.so.2': No such file or directory
You can now run: /usr/local/bin/aws --version

I tried setting export DOCKER_DEFAULT_PLATFORM=linux/amd64 or docker build --platform linux/amd64 -t php5 --progress=plain --no-cache . or docker run -d --name webserver5 --platform linux/amd64 -p 8888:80 -v /Users/avinda-blrm24/workspace:/sandbox php5 runnning like this but no use.

Machine details where I am running Docker desktop

OS : macOS Sonoma Chip : Apple M3 Pro Docker desktop version : 4.33.0 (160616) Any help ?


Solution

  • since its alpine image, add glibc and awscli like below and try

    ARG GLIBC_VERSION=2.35-r0
    ARG AWSCLI_VERSION=2.11.11
    
    # install glibc compatibility for alpine
    RUN apk --no-cache add \
            binutils \
            curl \
        && curl -sL https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub -o /etc/apk/keys/sgerrand.rsa.pub \
        && curl -sLO https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIBC_VERSION}/glibc-${GLIBC_VERSION}.apk \
        && curl -sLO https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIBC_VERSION}/glibc-bin-${GLIBC_VERSION}.apk \
        && curl -sLO https://github.com/sgerrand/alpine-pkg-glibc/releases/download/${GLIBC_VERSION}/glibc-i18n-${GLIBC_VERSION}.apk \
        && apk add --no-cache --force-overwrite \
            glibc-${GLIBC_VERSION}.apk \
            glibc-bin-${GLIBC_VERSION}.apk \
            glibc-i18n-${GLIBC_VERSION}.apk \
        && /usr/glibc-compat/bin/localedef -i en_US -f UTF-8 en_US.UTF-8 \
        && ln -sf /usr/glibc-compat/lib/ld-linux-x86-64.so.2 /lib64/ld-linux-x86-64.so.2 \
        && curl -sL https://awscli.amazonaws.com/awscli-exe-linux-x86_64-${AWSCLI_VERSION}.zip -o awscliv2.zip \
        && unzip awscliv2.zip \
        && aws/install \
        && rm -rf \
            awscliv2.zip \
            aws \
            /usr/local/aws-cli/v2/current/dist/aws_completer \
            /usr/local/aws-cli/v2/current/dist/awscli/data/ac.index \
            /usr/local/aws-cli/v2/current/dist/awscli/examples \
            glibc-*.apk \
        && find /usr/local/aws-cli/v2/current/dist/awscli/botocore/data -name examples-1.json -delete \
        && apk --no-cache del \
            binutils \
            curl \
        && rm -rf /var/cache/apk/*