2

I'm transitioning from a MacBook i9 chip to a MacBook M2 chip. I would like to build multi-arch docker images that support both linux/amd64 and linux/arm64. I can build and run on either computer but when I try to run the amd64 build on the arm64 computer I get this error:

rosetta error: failed to open elf at /lib64/ld-linux-x86-64.so.2

When I try to run the arm64 build on the amd64 computer this is the error:

qemu-aarch64: Could not open '/lib/ld-linux-aarch64.so.1': No such file or directory

The image manifest shows the two builds.

{
   "mediaType": "application/vnd.oci.image.index.v1+json",
   "schemaVersion": 2,
   "manifests": [
      {
         "mediaType": "application/vnd.oci.image.manifest.v1+json",
         "digest": "sha256:116ac56b8bf2e7535ded9b51864097fa14c1ede90d70b41b7a16807bbb824cda",
         "size": 1051,
         "platform": {
            "architecture": "amd64",
            "os": "linux"
         }
      },
      {
         "mediaType": "application/vnd.oci.image.manifest.v1+json",
         "digest": "sha256:083db49717725e61b15927b4fe0f5a779802bc7e1b01e216c6f4e77d981b77de",
         "size": 1051,
         "platform": {
            "architecture": "arm64",
            "os": "linux"
         }
      },
      {
         "mediaType": "application/vnd.oci.image.manifest.v1+json",
         "digest": "sha256:0a1538b844bf6800f74a6f85da0ae1e755176cb2545a2fed64ef3d7de2e9fb63",
         "size": 566,
         "annotations": {
            "vnd.docker.reference.digest": "sha256:116ac56b8bf2e7535ded9b51864097fa14c1ede90d70b41b7a16807bbb824cda",
            "vnd.docker.reference.type": "attestation-manifest"
         },
         "platform": {
            "architecture": "unknown",
            "os": "unknown"
         }
      },
      {
         "mediaType": "application/vnd.oci.image.manifest.v1+json",
         "digest": "sha256:67867ec55873cb43d562f86a1933d3933d6d5b9dc60d97899b9dc9adc22d664a",
         "size": 566,
         "annotations": {
            "vnd.docker.reference.digest": "sha256:083db49717725e61b15927b4fe0f5a779802bc7e1b01e216c6f4e77d981b77de",
            "vnd.docker.reference.type": "attestation-manifest"
         },
         "platform": {
            "architecture": "unknown",
            "os": "unknown"
         }
      }
   ]
}

To reproduce this create a new quarkus app:

quarkus create app --extensions=io.quarkus:quarkus-resteasy,io.quarkus:quarkus-container-image-docker multi-arch

Add these properties to the application.properties file.

# Default Image
quarkus.docker.buildx.platform=linux/amd64,linux/arm64
quarkus.container-image.group=<YOUR_GROUP>
quarkus.container-image.registry=<YOUR_REGISTRY>
quarkus.container-image.name=multi-arch
quarkus.container-image.tag=docker
quarkus.container-image.push=true

Build with this command

/mvnw clean package -Pnative -Dquarkus.native.container-build=true -Dquarkus.container-image.build=true

Run the new container image in docker.

docker run  -p 8080:8080 <YOUR_REGISTRY>/<YOUR_GROUP>/multi-arch:docker

Verify it is running:

http://localhost:8080/hello

This only happens with native images. JVM images work fine. I've verified that the Dockerfile.native base image registry.access.redhat.com/ubi8/ubi-minimal:8.6 is multi-arch.

0 Answers0