Docker image not working on linux/amd64
jeremiemartel opened this issue · 2 comments
Describe the bug
Cannot run a container using image from docker hub on linux/amd64 platform.
To Reproduce
docker run --rm clevy/csml-engine:latest
exec /bin/sh: exec format error
Expected behavior
Supposed to launch csml engine.
Additional context
It looks like you are copying compiled binaries in Dockerfile instead of building it inside docker image, and you copied arm binary and not amd version.
@jeremiemartel Probably any updates on this? I'm having the same issue, no idea what to do next.
Hi,
I had no answer, project seems to be dead, the solution I used (probably not the best) is to build my own docker image with pre compiled binaries, and add a script to select binary to execute depending on architecture.
My File architecture:
| Dockerfile
| pre_build.sh
| src
| | choose_server.sh
| | bin
| | | csml-server-linux-aarch64
| | | csml-server-linux-amd64
Dockerfile
FROM --platform=$TARGETPLATFORM ubuntu:22.04
ARG TARGETPLATFORM
WORKDIR /usr/src/csml
RUN apt update && apt install -y wget ca-certificates libpq-dev entr python3-minimal python3.10-venv && apt clean
RUN update-ca-certificates
# install csml server
COPY ./tmp/bin ./bin
COPY ./tmp/choose_server.sh .
RUN bash ./choose_server.sh && rm ./choose_server.sh
RUN chmod 755 server
ENTRYPOINT ["./server"]
pre_build.sh
#!/bin/bash
set -e
cd $(dirname $0)
mkdir -p tmp tmp/bin
cp ./src/choose_server.sh ./tmp
cp ./src/bin/csml-server-linux-aarch64 ./src/bin/csml-server-linux-amd64 tmp/bin
choose_server.sh
#!/bin/bash
set -e
if [ "$TARGETPLATFORM" == "linux/amd64" ] ; then
mv ./bin/csml-server-linux-amd64 server
rm -rf bin
elif [ "$TARGETPLATFORM" == "linux/arm64" ] ; then
mv ./bin/csml-server-linux-aarch64 server
rm -rf bin
else
echo "Invalid target platform: $TARGETPLATFORM"
exit 1
fi
Hope this can help.