Score:0

Moving docker container from linux based server to AWS

in flag

I am trying to move a container running on a linux based server to AWS. I am doing a commit-save-load.

After doing a commit-save-load, a docker image is created. I then ran this docker image using command

docker run <image_name>

But I get the following error

The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested

standard_init_linux.go:228: exec user process caused: exec format error

I tried running the docker image using

docker run --platform linux/amd64 <image_name>

Even that didn't resolve the issue. Got the same error

Score:1
ca flag

You can't just run a amd64 image (to be more precise, the same digest of the image) on an ARM platform, even if the image it's based on is multiplatform-featured.

in other words, it will not work with commit/save/load procedure.

The image itself usually needs to be built (docker buildx build --platform linux/arm64/v8,linux/amd64,...) based on a Dockerfile for every target platform.

In case you don't have the Dockerfile (bad habits), you can try to reverse engineer the Dockerfile from an image (to a certain level) using docker history and/or https://github.com/mrhavens/Dedockify

Albeit buildx is the correct way to do it, you can - for simplicity - just legacy-build (docker build) the image directly on your aws ARM machine if you just want to get it running once and quickly

(still requires a Dockerfile – it's not possible to convert an image to another platform)

sgohl avatar
ca flag
I wouldn't mention it in the answer, but if you chose the ARM platform by accident, just launch a x86_64 machine (any non a* instance type)
The Beast avatar
in flag
Oh .. understood. Thanks
The Beast avatar
in flag
Is there a way to build a Multi-Architecture Docker image from a container?
Score:0
cn flag

If you install Qemu on the AWS Arm machine you could potentially run x86_64 image, but this will be on an emulated CPU which will have a large overhead on performance.

Assuming an Debian/Ubuntu based host machine

sudo apt-get install qemu binfmt-support qemu-user-static 
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
docker run --platform linux/amd64 <image_name>

The first command installs the emulation layer, the second tells the kernel where to find the emulators to run the container in, you will need to do the second step every time the host machine is rebooted.

As stated both here and on your other question the correct thing to do is to use a Dockerfile to build your containers as that way you will have a repeatable way to build your container for any architecture you require (you can also use the steps I mentioned above to build the image for Arm64 on your X86_64 machine as described here)

The Beast avatar
in flag
Got it .. thanks
cn flag
@TheBeast https://serverfault.com/help/someone-answers
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.