I have an amd64 Ubuntu 20.04 based image. It works fine on the Linux host. I wanted to send it to a friend (
docker save &
docker load -i or push to Docker Hub - actually, I need both), so he can create a container based on that image on his MacOSX, but he got a bunch of warnings with regards to the architecture. I do not want to use Docker-files or have some convoluted configuration for multiple architectures. All I need is to convert one image into whatever MacOSX architecture is and, possibly, also arm64.
I’ve been reading through the docker build and buildx documentation and have been trying to accomplish something with it for roughly 2 days, but I probably misunderstand some kind of important concept. It all seems needlessly over-complicated from my point of view - no disrespect, but for such a relatively in-demand task the solution should not involve reading 10 pages and asking on a forum.
Can anyone suggest a solution that’s easily digestible? I would appreciate it very much. Thank you.
You can’t convert an image to an other architecture. Everything in that image is built for a specific architecture. I mean every binary file. If you don’t have anything in your Dockerfile that is architecture specific, then you can just move the Dockerfile and every dependency to an other machine and build it there. If you have Docker Desktop or you configured QEMU on linux, you can build your ARM64 image on an AMD64 machine. Building with QEMU does not always work, but it usually does.
It works only if the base image has also a version for that architecture.
So what would be the best approach? Get another PC and just create an image from scratch? I also read that
docker export exports the filesystem. Would it work to import that filesystem into an image/container created on a machine with a different architecture?
And also, by looking at it, this image (which my image is based off) DOES support many architectures. So it should just work on MacOSX, shouldn’t it? The only thing I did to my image though, I squashed it. Could this have affected the architecture compatibility?
No, it would not work. Export and import will not rebuild binaries. That is just like copying files to an other machine.
If you can get an other PC, then yes. If you can’t, then you can still try QEMU. Some CI/CD service can also give you different machines for building like CircleCI or Travis. I think The automated build on Docker Hub does not support it yet.