lima icon indicating copy to clipboard operation
lima copied to clipboard

PoC: Allow loading images by name from imagestore

Open afbjorklund opened this issue 1 year ago • 3 comments

This allows you to have a template like:

images:
- ubuntu-24.04
mounts:
- location: "~"
- location: "/tmp/lima"
  writable: true

Loading from another document like:

images:
# Try to use release-yyyyMMdd image if available. Note that release-yyyyMMdd will be removed after several months.
- location: "https://cloud-images.ubuntu.com/releases/24.04/release-20240423/ubuntu-24.04-server-cloudimg-amd64.img"
  arch: "x86_64"
  digest: "sha256:32a9d30d18803da72f5936cf2b7b9efcb4d0bb63c67933f17e3bdfd1751de3f3"
- location: "https://cloud-images.ubuntu.com/releases/24.04/release-20240423/ubuntu-24.04-server-cloudimg-arm64.img"
  arch: "aarch64"
  digest: "sha256:c841bac00925d3e6892d979798103a867931f255f28fefd9d5e07e3e22d0ef22"
# Fallback to the latest release image.
# Hint: run `limactl prune` to invalidate the cache
- location: "https://cloud-images.ubuntu.com/releases/24.04/release/ubuntu-24.04-server-cloudimg-amd64.img"
  arch: "x86_64"
- location: "https://cloud-images.ubuntu.com/releases/24.04/release/ubuntu-24.04-server-cloudimg-arm64.img"
  arch: "aarch64"

This makes it more similar to an OCI registry (or Vagrant), and allows for even using one (or IPFS) in the future.

  • #824

Perhaps "images" isn't the best name, since unlike a vagrant box there are no images contained in the directory.

~~The current implementation is just using the yaml filename, rather than the "name" field in the document itself.~~

Closes #2418 Closes #2422

afbjorklund avatar Jun 08 '24 13:06 afbjorklund

It would be possible to have both of them in the same yaml file, as separate documents. Like for "exporting"...

Then you would fill in the value of the current image name, with the location and digests of the current images.


image: ubuntu:24.04
mounts:
- location: "~"
- location: "/tmp/lima"
  writable: true
---
name: "ubuntu:24.04"
images:
# Try to use release-yyyyMMdd image if available. Note that release-yyyyMMdd will be removed after several months.
- location: "https://cloud-images.ubuntu.com/releases/24.04/release-20240423/ubuntu-24.04-server-cloudimg-amd64.img"
  arch: "x86_64"
  digest: "sha256:32a9d30d18803da72f5936cf2b7b9efcb4d0bb63c67933f17e3bdfd1751de3f3"
- location: "https://cloud-images.ubuntu.com/releases/24.04/release-20240423/ubuntu-24.04-server-cloudimg-arm64.img"
  arch: "aarch64"
  digest: "sha256:c841bac00925d3e6892d979798103a867931f255f28fefd9d5e07e3e22d0ef22"
# Fallback to the latest release image.
# Hint: run `limactl prune` to invalidate the cache
- location: "https://cloud-images.ubuntu.com/releases/24.04/release/ubuntu-24.04-server-cloudimg-amd64.img"
  arch: "x86_64"
- location: "https://cloud-images.ubuntu.com/releases/24.04/release/ubuntu-24.04-server-cloudimg-arm64.img"
  arch: "aarch64"

Here the "image" and "name" are optional, since it is self-contained and only needs to be merged.

afbjorklund avatar Jun 08 '24 13:06 afbjorklund

The goal was to make the usage of Lima more similar to a Vagrantfile or a Dockerfile.

Vagrant.configure("2") do |config|
  config.vm.box = "cloud-image/ubuntu-24.04"
end
  • https://app.vagrantup.com/cloud-image
FROM ubuntu:24.04
  • https://hub.docker.com/_/ubuntu

Should probably open a new ticket for discussion about that, old one was just "reuse"

  • #824

  • #2406

EDIT: #2418

afbjorklund avatar Jun 10 '24 06:06 afbjorklund

Now allows using "default" instead of the default name (currently ubuntu-22.04)

Maybe something similar should be added for mounts, to get the default mounts?

# This template requires Lima v0.7.0 or later.
images:
- default

mounts:
- default
func defaultMounts() []Mount {
        return []Mount{
                {
                        Location: "~",
                        Writable: ptr.Of(false),
                },
                {
                        Location: "/tmp/lima",
                        Writable: ptr.Of(true),
                },
        }
}

https://github.com/lima-vm/lima/blob/master/examples/ubuntu.yaml

afbjorklund avatar Jun 16 '24 11:06 afbjorklund