Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible to alter arm64 images on amd64 machine? #18

Open
dkebler opened this issue May 23, 2023 · 8 comments
Open

Possible to alter arm64 images on amd64 machine? #18

dkebler opened this issue May 23, 2023 · 8 comments

Comments

@dkebler
Copy link

dkebler commented May 23, 2023

Using moby buildkit and buildx bake I can build arm64 images on my amd64 machine. Is there a way to use your script to alter an arm64 image but doing so on a amd64 machine? I assume it would, like moby buildkit, have to do so in a dockerized arm64 container using qemu.

@gdraheim
Copy link
Owner

The script is in python but it depends a few external tools like "docker" and "tar" to save an image to disk and to unpack that archive. The question is whether that docker save and load routines can be replaced by the tools that you use to manage the docker images. Note that "podman" was designed as a drop-in replacement for the "docker" client command and it still showed problems. So.... if you can figure out how to save/load an image archive then it should work.

@gdraheim
Copy link
Owner

(no response)

@q0rban
Copy link

q0rban commented Jun 12, 2023

The question is whether that docker save and load routines can be replaced by the tools that you use to manage the docker images.

Last time I checked, there wasn't a way to save an image to disk with docker buildx.

@gdraheim
Copy link
Owner

If you can see the buildx results in "docker images" then all should be fine. If it uses containerd directly then check "ctr images" where ctr has also import/export commands. That's my best guess.

@gdraheim gdraheim reopened this Jun 12, 2023
@q0rban
Copy link

q0rban commented Jul 4, 2023

Okay, so I investigated this again. It is possible to save the built image to docker images with docker buildx using the --load option. The limitation for my use case is that it's not possible to build multi-platform images using the --load option. So, for the original requester, if you just want to build and alter an arm64 image on an amd64 machine, this is possible with buildx. However, I cannot figure out how to alter an arm64/amd64 (multi-platform) image. I can output a multi-platform in OCI format, but not docker image format. Or I can output individual images for each platform in docker image format, but I'm not sure if it's possible to then compile those distinct images into a single multi-platform image.

@q0rban
Copy link

q0rban commented Jul 4, 2023

The one way I've thought about altering a multiplatform image is to run a local registry and push the multiplatform image from buildx to there, then pull the image from the local registry, save it, make the alterations, and load it.

@q0rban
Copy link

q0rban commented Jul 4, 2023

One advantage to docker buildx, is that it seems that it's possible to skip the step of docker save by using --output type=docker,dest=- which outputs a docker image tarball:

docker buildx build --platform linux/arm64 --output type=docker,dest=- . | tar -C path/to/tmp -x
# perform alterations using manifest.json and config and then reload:
tar -C path/to/tmp -c . | docker load

@dkebler
Copy link
Author

dkebler commented Jul 5, 2023

As of three weeks ago (and no simple way to do this) I opted to build my image from scratch instead of building from one with an unwanted VOLUME I then needed to remove using this tool. Still if I find another situation where I couldn't do that I'd revisit this. Thx anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants