beingadityak
beingadityak

Reputation: 109

Is it possible to build an arm64 image from an existing x86-64 image?

I have a scenario where I'm provided access to a customer's AWS environment (except to the code base) and the customer is having their images present on AWS ECR. I have an EKS kubernetes node pool which consists of Graviton (ARM) servers. I have a requirement to rebuild the image from the existing one to an arm64 architecture without having any sort of access to the code base.

I wanted to ask whether is it possible to achieve this and what are the steps that should be followed? (high-level steps are okay).

I know of the step for copying the image (this is helpful) but not sure for the architecture step.

Upvotes: 3

Views: 3176

Answers (1)

Noam Yizraeli
Noam Yizraeli

Reputation: 5394

As @BMitch truthfully noted the basic answer is a hard cold No.

Now that that's out of the way how might we attempt such a thing?

the easiest way (and less time consuming)

is using an emulator, as suggested here (he also mentioned some examples for Linux as you are one with the original containers), the emulator can run the containers them selfs (like a VM or Docker Desktop with its feature) but I'd take that with a grain of salt, even a big influencial company like Apple using an emulator as a bridge for unready software.

If you want more and have more time:

let's start from the easy ones - Java, python, bash, and other interpreted languages

If using one of these it's as "easy" as copying the project files (manually figuring out dependencies from the code, though versions is a doozy) preparing the new container with the language runtime programs and libs, copying everything to the new environment, and setting up all that's needed, and that's if the previous step with figuring out the dependencies was hopefully successful.

If using java only copy the .jar file, use the same JRE (Java Runtime Environment) and you should be good to go, check out this post for and exception

If using python or Javascript as long as you can get the libraries they're using (with specific versions) you're fine and in a similar situation to Java

bash probably wont care as long as you have all the scripts you need

Now, if you are an adventurous person and you think you can beat fortune 500 companies and this is a good use of your time come for the ride.

If talking about compiled languages like C, C++, Golang and others

Then you're about to have fun translating x86 or amd64 assembly (or better machine code) into ARM assembly code, here's an example of a person trying to pull a similar thing. Joking aside that's what emulators do in realtime so either use a well-known emulator (that might kill your performance and CPU time budget) or intentionally translate each program by hand (optimizing for ARM along the way)

If being assisted by them is possible

docker has a feature when building a docker image to do so for multiple platforms (architectures) with buildkit (using the docker buildx docker command) that follows 3 paths:

  • first we mentioned, using an emulator like QEMU
  • second (and probably not so relevant) is having multiple nodes with diferent architectures to mitigate that
  • and third is creating a multiplatform Dockerfile that make it easy do create a single dockerfile with different stages for each platform and common stages for parts that are similar between architectures

here's also a docker article on the matter for further research

Upvotes: 5

Related Questions