IBM Cloud Code Engine: Locally built container image gives exec format error when deployed
I have created a container image on my machine (Mac). When testing it locally, all works fine. But the following does not work:
- Push the image to the Container Registry in IBM Cloud
- Create an application in Code Engine using the image
It produces this error:
exec /usr/local/bin/docker-entrypoint.sh: exec format error
I’ve looked in to the docker-entrypoint.sh and that seems to be ok. What is wrong? How do I address it?
Solution – 1
Code Engine runs on x86 machines internally. In order to push an image to CE that has been built on a M1 Mac, please add
docker build --platform linux/amd64 ... when you do your docker build.
Solution – 2
The reason for the problem is the chip architecture. IBM Cloud Code Engine is based on the Intel x86 architecture, many Mac computers use ARM 64 (M1 or similar). There are two options to work around it:
- Use Code Engine to build the container images.
docker build --platform linux/amd64to specify the build platform in your local builds.
Solution – 3
Which CPU do you have on your Mac? Currently, Code Engine can’t run images that have been build on a M1 ARM 64 machine.
You can add this parameter your local docker build command..
docker build --platform linux/amd64 ...
Or you can use a Code Engine Build to do it for you.