tianon / docker-qemu

Dockerization of supported QEMU releases
https://qemu.org
133 stars 34 forks source link

use alpine as base image? #40

Closed psy0rz closed 1 year ago

psy0rz commented 1 year ago

Would this be possible, or is there a special reason you compile qemu yourself?

The current stable version of alpine has qemu 7.0.

tianon commented 1 year ago

use alpine as base image?

I don't use Alpine as a base image here because Debian is typically more well-supported by upstreams and it includes extra packages like ovmf, qemu-efi-aarch64, etc that make my life easier (and more folks have written guides for doing things with QEMU on Debian-based distributions than Alpine).

There's not really a technical reason why it shouldn't work (that I'm aware of), but mostly personal preference.

is there a special reason you compile qemu yourself?

This one's a two-parter - I like having the latest official upstream releases (which is not the purpose or goal of most distributions/packages) and there's not a huge amount of value in a two-line Dockerfile (FROM foo, RUN package-manager install bar).

tianon commented 1 year ago

(Also the sheer size of compiled builds of QEMU make me doubt that an Alpine-based image really would be significantly smaller, and size is typically the motivator I see when folks turn to Alpine-based images.)

psy0rz commented 1 year ago

well, i tried, the difference in size is astounding:

test                        latest    aec5d13d3dc4   5 minutes ago   61.7MB
tianon/qemu                 latest    4adcb3e7e942   2 days ago      1.54GB

I only installed qemu-system-x86_64:

psy@psyt14s:~/ansible$ docker run -it --rm test-qemu
/ # qemu-system-x86_64 --version
QEMU emulator version 7.0.0
Copyright (c) 2003-2022 Fabrice Bellard and the QEMU Project developers
/ # 
psy@psyt14s:~/ansible$ docker run -it --rm tianon/qemu /bin/bash
root@97e39562ada2:/# qemu-system-x86_64 --version
QEMU emulator version 7.1.0 (https://github.com/tianon/docker-qemu)
Copyright (c) 2003-2022 Fabrice Bellard and the QEMU Project developers
psy0rz commented 1 year ago

(i offcourse tried and it boots my .iso)

psy0rz commented 1 year ago

a very interesting side effect: your compiled version reacts correctly to a SIGHUP.

when i use the qemu binary from alpine or ubuntu, it just terminates immeadiatly on a SIGHUP without shutting down the VM operating system correctly. (via acpi)

also the size of your image seems to be 507Mb now?

psy0rz commented 1 year ago

ah https://github.com/tianon/docker-qemu/blob/master/7.1/qemu-signals.patch

berlin4apk commented 1 year ago

@psy0rz can you publish your work? so i can use it as the base for a PR to add, a Alpine-based image, it as a slim size alternative docker image version.

@tianon Im also running in problems with the docker image size. (getting spamed with "No space left on device" on my docker hosts :-) )

tianon commented 1 year ago

If you're not already using the "native" variants and are only using KVM and not emulation, you should definitely consider switching (they're only ~500MiB instead of 1.5GiB, and only support a single architecture instead of a huge number of architectures).