Build an initramfs image in a docker container(fedora 34)

my idea is to use 1jo1/fedora-netty-build as my docker image to build a kernel image and create an initramfs image to boot fedora 34 cloud via QEMU


  • docker custom docker image here my Dockerfile
  • kernel 5.12.9 compile image and install the modules(/usr/lib/modules) in a container
  • dracut version: 054-12.git20210521.fc34
  • docker version 20.10.6

when I run dracut in a docker container
dracut /linux-5.12.9/initramfs-5.12.img 5.12.9

dracut: WARNING: running in hostonly mode in a container!!
findmnt: can't read (null): No such file or directory

I’m just wondering the initramfs image is only 42MB, compare to 700 MB when I build it on the host machine(arch linux)

is there a way to create an initramfs in a docker container?

when run dracut in Arch Linux base docker image, I didn’t get any warning/error message

I have never tried to do what you are doing but 700MB is unreasonably huge for an initramfs. Are you sure there isn’t something wrong there? That would mean that you could only fit a single initramfs in a 1GB /boot partition.

Also, initrds are install specific so to take one from another place and use it would require an identical configuration in both places.

tbh I dont why initramfs is so huge…probably because I build initramfs in arch linux, yeah I compiled the kernel and I used fedora kernel config as base config
a lot of modules are missing when I try to boot fedora with initramfs which are built in docker container(fedora), whole networking is not working and usb etc. is not working

for example when I build initramfs in fedora(qemu) I didn’t get any warning/error message, the size of initramfs is around 70MB, qemu boot works perfectly :slight_smile: (the network,usb etc. module are found)