How to make a container that is compatible across architectures or a workaround?

I recently encountered an issue while migrating containers between architectures. I had an amd64 container on my previous host, but I discovered that containers can’t be directly migrated to a server with an ARM CPU. To complicate matters, my ARM server has virtualization disabled, so using VMs to work around the architecture difference isn’t an option.

Now, if I decide to fully commit to the ARM server and set up my environment there, I’m worried that I’ll face the same issue in the future when trying to migrate those containers back to an amd64 host.

I’m looking for a solution that can overcome this architecture lock-in. Is there a way to create or use containers that are cross-architecture compatible without relying on nested virtualization? For example, is there a type of container image or technology that works seamlessly across both ARM and amd64?

Any guidance or suggestions would be greatly appreciated

There is no such thing, all binaries are completely different between architectures and architecture emulation is basically impossible for containers (qemu-user-static isn’t in any way reliable enough for production workloads) and for VMs, architecture emulation is technically possible but Incus only supports hardware accelerated VMs so it doesn’t support that, not that it would be a good idea anyway as full architecture emulation burns a LOT of CPU as you effectively need to fully emulate another CPU with close to no hardware acceleration.

So anyway, if you expect to have to go back and forth between architectures, your best bet is to automate the creation of that container / VM so that you can quickly re-deploy it from scratch on another architecture.

If you are looking for a pure " technology " point of view (and not Containers) then that’s what Java is all about right ? (Write Once, Run Anywhere). You compile your Java code for a JVM. There are JVMs available for many architectures and your code should run fine independent of the underlying architecture - well, at least that’s the theory. But then like everything else, the devil is in the details :slight_smile: