standard_init_linux.go:228: exec user process caused: exec format error

Jessica Bai 5 Reputation points
2023-05-20T01:23:44.34+00:00

docker image build on local mac using cmd ,docker buildx build --no-cache --platform linux/amd64,linux/arm64 -t myapi. pushed to azure using cmd docker push $NAME.azurecr.io/myapi resource group and registry created successful,

docker run --name myapi -p 80:80 -m 1.5G $NAME.azurecr.io/myapi failed with error

standard_init_linux.go:228: exec user process caused: exec format error

any help will appreciated

Azure Container Instances
Azure Container Instances
An Azure service that provides customers with a serverless container experience.
676 questions
{count} vote

1 answer

Sort by: Most helpful
  1. vipullag-MSFT 26,021 Reputation points
    2023-05-22T10:08:03.9366667+00:00

    Hello Jessica Bai

    Welcome to Microsoft Q&A Platform, thanks for posting your query here.

    Based on the issue description, looks like the error is caused by a mismatch in the architecture of the container image and the host machine. The error message "standard_init_linux.go:228: exec user process caused: exec format error" usually indicates that the binary format of the container image is not compatible with the host machine. This could happen if you are trying to run an ARM64-based image on an AMD64-based machine or vice versa.

    Based on the command you used to build the image, it seems like you are building a multi-architecture image that supports both linux/amd64 and linux/arm64. However, when you run the container using the docker run command, it seems like you are running it on a machine that does not support the arm64 architecture.

    To fix this issue, you can try running the container on a machine that supports the arm64 architecture. Alternatively, you can try building the container image only for the linux/amd64 architecture, which is the most common architecture for servers and desktops.

    To build the container image only for the linux/amd64 architecture, you can use the following command**:**

    docker build --no-cache --platform linux/amd64 -t myapi .
    

    This command will build the container image only for the linux/amd64 architecture. You can then push the image to Azure Container Registry and try running it on a machine that supports the linux/amd64 architecture.

    I hope this helps.

    If the suggested response helped you resolve your issue, please 'Accept as answer', so that it can help others in the community looking for help on similar topics.

    1 person found this answer helpful.