gotoz / runq

run regular Docker images in KVM/Qemu
Apache License 2.0
797 stars 45 forks source link

Support release image on modern docker, upgrade guest distro to 22.04 #27

Open ConnorNelson opened 11 months ago

ConnorNelson commented 11 months ago

The first commit fixes #24. It is not clear if #18 is still relevant, but it seems like passing --init is simpler to guarantee our docker-init.

The second commit brings the guest distro to ubuntu 22.04 (Linux 5.15.0-87-generic as of this PR).

pmorjan commented 11 months ago

Thanks for the PR.

The first commit looks good to me. I think we don't have to support overriding DOCKER_INIT if we instead search for docker-init in $PATH. Your changes and this should make it work with old and new Docker:

Regarding Ubuntu 22.04 Is there a special reason for switching to 22.04? Keep in mind that we must also support s390x. I would prefer to stay on 20.04 for now unless there is a good reason to switch. But we could put an additional Dockerfile.2204 in qemu/x86_64/ together with your change in qemu_amd64.go for people who want to try out 22.04.

ConnorNelson commented 11 months ago

So the issue with searching $PATH for docker-init is that modern installs put it at /usr/libexec/docker/docker-init, which is not in $PATH. We can of course search $PATH:/usr/libexec/docker.

It's not clear to me what the downsides are of --init, but I'm happy to switch the PR to either strategy, just let me know which you prefer and I'll update the PR.


As for Ubuntu 22.04, there isn't a specific reason other than getting a newer kernel (I need some newer features). The s390x part of this project is irrelevant to me, but I understand the concern for maintaining support for it. Another option here (though maybe too-clever) would be to parameterize FROM ubuntu:20.04, e.g.:

ARG UBUNTU_VERSION=20.04
FROM ubuntu:$UBUNTU_VERSION

The we have the Makefile pass through an optional --build-arg UBUNTU_VERSION=22.04.

However, the downside, and where we'll introduce some more complexity is that we'll need some system for constructing kernel.conf dependent on our kernel version. For example, in our ubuntu:22.04 version, we needed to add netfs.ko. If you know what are core requirements are, we can dynamically construct this dependency list using lib/modules/*/modules.dep. Or probably, even better, change the logic of init to remove loadKernelModules/kernel.conf and instead use logic more similar in modprobe.go to automatically resolve these dependencies at runtime (probably a tiny performance hit in parsing modules.dep at runtime).

Alternatively, we can add a Dockerfile.2204 and have the Makefile take care of that optionally. However, there may be interest in 24.04 next year 😉.

Again, let me know what strategy you prefer, and I'd be happy to update the PR.

pmorjan commented 11 months ago

I'm sorry for the confusing regarding the PATH. In all my systems the mount path is always /sbin/docker-init. So your commit is ok. But we could consider removing the check in initrd/Makefile. With your changes it's no longer needed. So please create a PR with your first commit.

pmorjan commented 11 months ago

If /sbin/docker-init does not exist we could simple try to copy from /usr/libexec/docker/docker-init to support "modern installs". You can add this to your PR if you like.

pmorjan commented 11 months ago

Regarding 22.04 I would prefer a second Dockerfile. If we integrate a second distro/version then we must always test and support it. The base kernel modules are copied into the initrd. Therefore we need the kernel.conf. I think we should make it possible to use 22.04+ but I don't want to switch now nor support two versions. There are other things waiting to be fixed, e.g. removing 'pkg/errors'. A 2nd. PR with a Dockerfile.2022 and maybe some instructions in the readme on how to use it is very welcome.

pmorjan commented 4 months ago

Thanks @ConnorNelson See branch ubuntu2204.