bootloose icon indicating copy to clipboard operation
bootloose copied to clipboard

investigate how to use LXD images

Open ncopa opened this issue 2 years ago • 4 comments

LXD maintains a lot of OS OCI images. It would be nice to be able to pull OS images from LXD. Needs investigation on how we can do this.

ncopa avatar Oct 25 '23 08:10 ncopa

I was able to extract the qcow2 from https://jenkins.linuxcontainers.org/view/Images/job/image-alpine/lastBuild/architecture=amd64,release=3.18,variant=default/ - I put it into disk.tar.gz and created a Dockerfile:

FROM scratch
ADD disk.tar.gz /

I can then run that image with /sbin/init like bootloose does. The start-up sequence ends with a loop trying to find a tty from /dev/tty1.../dev/tty4 for starting a console, but looks like it's "up" enough so that I can docker exec into it. Looks like everything is working, but there's no sshd preinstalled, other than that, it should probably work just fine as a "bootoose image". All bootloose does is that it starts a container with the command /sbin/init then docker execs into it and appends the ssh pubkey into /root/.ssh/authorized_keys.

There are go packages for interacting with the image server and reading qcow2 files, so I guess it would be possible to have bootloose download lxd images and create docker containers, but there would still have to be some customization for example to install sshd.

kke avatar Oct 25 '23 12:10 kke

Of course it could just start it as-is and if there's no sshd, so be it. Bootloose could include an exec command so you could do something like bootloose exec node0 /bin/bash to run a shell in the "machine" if there's no ssh.

kke avatar Oct 25 '23 12:10 kke

I wonder how/where lxd pulls the images from? https://images.linuxcontainers.org/

ncopa avatar Oct 25 '23 13:10 ncopa

Yes I think that's the repo, https://github.com/lxc/incus/tree/main/client somehow downloads images from there, there are some commits that mention images.linuxcontainers.com

kke avatar Oct 26 '23 07:10 kke