Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to solve Docker container exec format error for running entrypoint [duplicate]

Perviously the question was related to Yarn command not found after successful docker build. But it was fixed but my problem is related to using shell /bin/sh Here's What I am trying to do use yarn and install it on amazonlinux:2 image Here's my Dockerfile

FROM amazonlinux:2

RUN yum update -y && \
    yum install -y tar curl gzip zip unzip aws-cli

RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | sh && \
    . ~/.nvm/nvm.sh && \
    nvm install 14 && \
    nvm alias default 14 && \
    nvm use default && \
    npm install -g yarn

USER root

COPY .bashrc /root/.bashrc

COPY entrypoint.sh /root/entrypoint.sh

RUN chmod +x /root/entrypoint.sh

ENTRYPOINT [ "/root/entrypoint.sh" ]

And this is my .bashrc file

#!/bin/sh
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"

ANd this is my entrypoint.sh

#!/bin/sh
. /root/.bashrc
exec "$@"

All I get is while trying to run container from ECS exec /root/entrypoint.sh: exec format error and Essential container in task exited How to solve the exec format error?Please help me

like image 957
nitesh rijal Avatar asked Jun 28 '26 16:06

nitesh rijal


2 Answers

The exec format error message means that you have built your docker image on an ARM system like a Mac M1, and are trying to run it on an X86 system, or the opposite, building it on an X86 computer and trying to run it on an ARM system like an AWS Graviton environment.

You either need to use Docker BuildKit to build the image for the environment you intend to run it, or make sure that your build environment and deployment environment have the same CPU architecture.

like image 159
Mark B Avatar answered Jul 01 '26 05:07

Mark B


Had the same issue, turns out i had some whitespace before the shebang. SMH

like image 20
Christopher Ragira Avatar answered Jul 01 '26 07:07

Christopher Ragira



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!