I am pretty new to this Docker world and I am trying to deploy an image (nodejs-typescript service) from aws ECR to aws ECS but when I create the service inside the cluster this error appears and the taks never gets running:
exec /usr/local/bin/docker-entrypoint.sh: exec format error
My Dockerfile looks like this:
FROM node:lts-alpine
WORKDIR /usr/app
COPY package*.json ./
COPY tsconfig*.json ./
RUN yarn install --quiet
RUN yarn global add pm2
COPY . .
RUN yarn build
CMD ["pm2-runtime", "build/src/localServer.js"]
It is working fine on my pc when I build the image and run it:
(base) MacBook-Pro api % docker run -it -p 3000:3000 api-dev
2022-12-06T15:35:27: PM2 log: Launching in no daemon mode
2022-12-06T15:35:27: PM2 log: App [localServer:0] starting in -fork mode-
2022-12-06T15:35:27: PM2 log: App [localServer:0] online
Connected to my_mongo_db_cluster
š Server ready at: http://localhost:3000/
The task definition is running on Linux/X86_64.
Any suggestions or tips to find out what is the problem? Thanks!
EDIT: when I add an ENTRYPOINT to my Dockerfile like this
# same steps
COPY . .
RUN yarn build
ENTRYPOINT ["pm2-runtime", "build/src/localServer.js"]
it throw this error exec /usr/local/bin/pm2-runtime: exec format error
. The same happens when I change pm2-runtime
to node
# same steps
COPY . .
RUN yarn build
ENTRYPOINT ["node", "build/src/localServer.js"]
Hope it helps.
I found out what was the problem. It was my Apple M1 chip doing its incompatibility magic. For those who has the same problem, just adding the platform --platform=linux/amd64
in your Dockerfile seems to solve the problem:
FROM --platform=linux/amd64 node:lts-alpine
# more instructions...