Giter VIP home page Giter VIP logo

Comments (6)

deitch avatar deitch commented on June 6, 2024

Frankly, I do not understand why this is running under qemu at all. See on my arm64 Mac:

$ docker run -it --rm --entrypoint=sh linuxkit/mkimage-vmdk:b55ea46297a16d8a4448ce7f5a2df987a9602b27
# uname -m
x86_64
# ps 1
  PID TTY      STAT   TIME COMMAND
    1 pts/0    Ssl    0:00 /usr/bin/qemu-x86_64 /bin/sh sh

Same thing if I run it explicitly:

$ docker run -it --rm --platform=linux/arm64 --entrypoint=sh linuxkit/mkimage-vmdk:b55ea46297a16d8a4448ce7f5a2df987a9602b27
# uname -m
x86_64
# ps 1
  PID TTY      STAT   TIME COMMAND
    1 pts/0    Ssl    0:00 /usr/bin/qemu-x86_64 /bin/sh sh

No problems with other (e.g. alpine) images. And the manifest seems correct:

{
	"schemaVersion": 2,
	"manifests": [
		{
			"mediaType": "application/vnd.oci.image.manifest.v1+json",
			"digest": "sha256:0a39a85c03694769a9ac93fa709cc225fc177e81b177c250ca3682c69a1b9d63",
			"size": 865,
			"platform": {
				"architecture": "amd64",
				"os": "linux"
			}
		},
		{
			"mediaType": "application/vnd.oci.image.manifest.v1+json",
			"digest": "sha256:f545ce6b8fd28a1695bdb4952c093fa30bef55f5db8fdd25c7a4a6741f8784f4",
			"size": 865,
			"platform": {
				"architecture": "arm64",
				"os": "linux"
			}
		}
	]
}

as is the arm64 config:

{
  "architecture": "arm64",
  "config": {
    "Env": [
      "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
      "DEBIAN_FRONTEND=noninteractive"
    ],
    "Entrypoint": [
      "/make-vmdk"
    ],
    "Labels": {
      "org.mobyproject.linuxkit.revision": "unknown",
      "org.mobyproject.linuxkit.version": "unknown",
      "org.opencontainers.image.revision": "7b516aa6e8fda7869554161a9f11befc3f31e1b2",
      "org.opencontainers.image.source": "https://github.com/linuxkit/linuxkit"
    },
    "ArgsEscaped": true,
    "OnBuild": null
  },
  "created": "2022-12-29T23:43:47.935994083Z",
  "history": [
    {
      "created": "2017-12-12T01:44:20.97772974Z",
      "created_by": "/bin/sh -c #(nop) ADD file:eb2519421c9794ccc99d483c07f59ba305531bc9b4dc294e74d2ddb7de69e52a in / "
    },
    {
      "created": "2017-12-12T01:44:21.269562823Z",
      "created_by": "/bin/sh -c #(nop)  CMD [\"bash\"]",
      "empty_layer": true
    },
    {
      "created": "2018-01-25T13:00:48.786564417Z",
      "created_by": "/bin/sh -c #(nop)  ENV DEBIAN_FRONTEND=noninteractive",
      "empty_layer": true
    },
    {
      "created": "2018-01-25T13:02:32.488044378Z",
      "created_by": "/bin/sh -c apt-get update && apt-get -yq upgrade && apt-get install -yq libguestfs-tools syslinux linux-image-amd64 vim"
    },
    {
      "created": "2022-12-29T23:43:47.935994083Z",
      "created_by": "COPY . . # buildkit",
      "comment": "buildkit.dockerfile.v0"
    },
    {
      "created": "2022-12-29T23:43:47.935994083Z",
      "created_by": "ENTRYPOINT [\"/make-vmdk\"]",
      "comment": "buildkit.dockerfile.v0",
      "empty_layer": true
    }
  ],
  "moby.buildkit.buildinfo.v1": "eyJmcm9udGVuZCI6ImRvY2tlcmZpbGUudjAiLCJzb3VyY2VzIjpbeyJ0eXBlIjoiZG9ja2VyLWltYWdlIiwicmVmIjoiZG9ja2VyLmlvL2xpbnV4a2l0L2d1ZXN0ZnM6YTQwNjdmNGJkNWI4MTU0ODE5NWEzNWM3MTYzOGEzZDg1NzQxNTgxNyIsInBpbiI6InNoYTI1NjplZDI0MzEzYWFlZWQ4OTc0ZjYyNmIzZTNkMjUyNzgzZmY4OTQzZDdhZTBjNjczNTI2YTg4YTg1NzJmMjUxN2NkIn0seyJ0eXBlIjoiaHR0cCIsInJlZiI6Imh0dHA6Ly9idWlsZGtpdC1zZXNzaW9uLzNraDJ6ZG84MWgxeDhjdGR6cXZiazVqaGUiLCJwaW4iOiJzaGEyNTY6YjE5NDYwNGRlNDZkMTczM2UwZGFkYjYxMWM1NDQ4OWU4OTNiYjNiMTdmMDRhYzhjZTY5NWMxZDgwZDFkNjU3MyJ9XX0=",
  "os": "linux",
  "rootfs": {
    "type": "layers",
    "diff_ids": [
      "sha256:e27a10675c5656bafb7bfa9e4631e871499af0a5ddfda3cebc0ac401dfe19382",
      "sha256:934cb6db266090266ab85c259c8f6d33533746c572d8c049085a872af3aca215",
      "sha256:381c9d07f1c7c8332fefce3c2b8634f3122008d5328ad3fb7820b4ea045693c3"
    ]
  }
}

from linuxkit.

eszense avatar eszense commented on June 6, 2024

I think that's because the arm64 image actually contains x86-64 binary of qemu-img?

docker run -it --rm --entrypoint /bin/bash linuxkit/mkimage-vmdk:b55ea46297a16d8a4448ce7f5a2df987a9602b27-arm64 -c 'file $(which qemu-img)'

/usr/bin/qemu-img: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=1d4e7b1bb4fcd292c6407dacc87fd42e500a9a0e, stripped

from linuxkit.

deitch avatar deitch commented on June 6, 2024

Why should that matter? It can have whatever it wants inside it, but if my command is:

docker run -it --rm --platform=linux/arm64 --entrypoint=sh

Then the one thing it should explicitly launch is sh. Unless sh itself is the wrong arch, and docker itself is figuring that out and running qemu?

from linuxkit.

eszense avatar eszense commented on June 6, 2024

I think docker can detect wrong arch and involve emulation as needed:

docker run -it --rm alpine sh -c 'apk -q add file; echo "Native binary:"; file /bin/busybox; busybox uname -a; wget -q https://busybox.net/downloads/binaries/1.35.0-x86_64-linux-musl/busybox; chmod u+x busybox; echo "x86_64 binary:"; file ./busybox; ./busybox uname -a'
Native binary:
/bin/busybox: ELF 64-bit LSB pie executable, ARM aarch64, version 1 (SYSV), dynamically linked, interpreter /lib/ld-musl-aarch64.so.1, stripped
Linux e87569d9a44b 5.15.49-linuxkit #1 SMP PREEMPT Tue Sep 13 07:51:32 UTC 2022 aarch64 Linux
x86_64 binary:
./busybox: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, stripped
Linux e87569d9a44b 5.15.49-linuxkit #1 SMP PREEMPT Tue Sep 13 07:51:32 UTC 2022 x86_64 GNU/Linux

And mkimage-vmdk is based on linuxkit/guestfs, and from dockerhub linuxkit/guestfs only has amd64 image

from linuxkit.

deitch avatar deitch commented on June 6, 2024

Ah, is that it? guestfs is only amd64?

How interesting, and it is based on debian:stretch. I am assuming that is for the availability of vm-make-fs, guestfish and qemu-img.

qemu-img is available in Alpine, but not the others, unfortunately.

Looks like if we move from the older stretch to the newer bullseye, we can get the packages. Some packages have changed their naming structure, but it should be doable.

from linuxkit.

deitch avatar deitch commented on June 6, 2024

Looking a bit deeper, there are four downstream dependencies of the linuxkit/guestfs image. All four use the same basic tools: virt-make-fs, guestfish, qemu-img. It looks like libguestfs was available on alpine for a while, but now is not 🤷‍♂️

from linuxkit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.