[Azure Iot Edge]How to build arm64v8 docker image based on Ubuntu 18.04 amd64 OS by VS Code?

罗宇恒 罗宇恒 571 Reputation points
2021-04-23T12:40:17.88+00:00

How to build arm64v8 docker image based on Ubuntu 18.04 amd64 OS by VS Code?

I try to build it by VS Code, but it can not excute RUN command in Dockerfile:

Step 2/11 : RUN mvn org.apache.maven.plugins:maven-dependency-plugin:3.1.1:get -Dartifact=com.microsoft.azure.sdk.iot:iot-device-client:1.17.5 -DrepoUrl=https://repo.maven.apache.org/maven2/
 ---> [Warning] The requested image's platform (linux/arm64) does not match the detected host platform (linux/amd64) and no specific platform was requested
 ---> Running in dbb1381f9c56
standard_init_linux.go:219: exec user process caused: exec format error

Thanks.

Azure IoT Edge
Azure IoT Edge
An Azure service that is used to deploy cloud workloads to run on internet of things (IoT) edge devices via standard containers.
574 questions
0 comments No comments
{count} votes

Accepted answer
  1. 罗宇恒 罗宇恒 571 Reputation points
    2021-04-25T06:36:51.6+00:00

    I find a solution for this, we can use qemu-user-static to build arm64 docker image based on Ubuntu 18.04 Intel processor .

    Modify the Dockerfile as follow:

    FROM multiarch/qemu-user-static:x86_64-aarch64 as qemu #Add this line
    FROM arm64v8/maven:3.5-jdk-8-slim AS build-env
    
    COPY --from=qemu /usr/bin/qemu-aarch64-static /usr/bin #Add this line
    
    RUN mvn org.apache.maven.plugins:maven-dependency-plugin:3.1.1:get -Dartifact=com.microsoft.azure.sdk.iot:iot-device-client:1.17.5 -DrepoUrl=https://repo.maven.apache.org/maven2/
    
    WORKDIR /app
    COPY . /app
    RUN mvn install -Dmaven.test.skip=true
    ...
    
    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Sander van de Velde | MVP 32,726 Reputation points MVP
    2021-04-23T22:40:23.473+00:00

    Hello @罗宇恒 罗宇恒 ,

    I guess you try to build this image in VS Code on a Windows OS with an Intel/AMD processor.

    VS Code is available for Linux too!

    Have you tried to build it on an actual Arm64 device like the NVidia Jetson Nano?

    1 person found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.