turnkeylinux / tkldev-docker

1 stars 4 forks source link

dockerize.sh is crashing on Ubuntu 22.04 #1

Closed derMart closed 1 year ago

derMart commented 1 year ago

Trying to dockerize a turnkey iso. dockerize.sh is crashing on standard Ubuntu 22.04:

sudo ./dockerize.sh turnkey-tkldev-17.2-bullseye-amd64.iso 
+ [[ -z turnkey-tkldev-17.2-bullseye-amd64.iso ]]
+ for i in isoinfo unsquashfs sed docker
+ which isoinfo
+ for i in isoinfo unsquashfs sed docker
+ which unsquashfs
+ for i in isoinfo unsquashfs sed docker
+ which sed
+ for i in isoinfo unsquashfs sed docker
+ which docker
+ ISO=turnkey-tkldev-17.2-bullseye-amd64.iso
+ shift
+ echo turnkey-tkldev-17.2-bullseye-amd64.iso
+ grep -q /turnkey-tkldev
++ basename turnkey-tkldev-17.2-bullseye-amd64.iso .iso
+ NAME=turnkey-tkldev-17.2-bullseye-amd64
+ trap 'rm -rf squashfs-root 10root.squashfs' EXIT INT
+ [[ turnkey-tkldev-17.2-bullseye-amd64 = \c\o\r\e ]]
+ isoinfo -i turnkey-tkldev-17.2-bullseye-amd64.iso -x '/LIVE/10ROOT.SQUASHFS;1'
+ unsquashfs -no-exit-code 10root.squashfs
Read on filesystem failed because EOF
FATAL ERROR: Can't find a valid SQUASHFS superblock on 10root.squashfs
+ rm -rf squashfs-root 10root.squashfs

Also it would be kind of a little more trustworthy if dockerize.sh would not need sudo rights. I don't actually see why extracting an iso image, changing some files and generating a docker image out of this would need root rights...?

derMart commented 1 year ago

had to change isoinfo -i "$ISO" -x '/LIVE/10ROOT.SQUASHFS;1' > 10root.squashfs into

isoinfo -R -i "$ISO" -x '/live/10root.squashfs' > 10root.squashfs

so for me the -R option had to be included, as well as lowercase the path inside the iso as it seems case sensitive and remove ;1 which I frankly don't know what this is supposed to do.

EDIT: Using isoinfo 1.1.11 (Linux) version here.

derMart commented 1 year ago

Also the generated local docker repositoy name is not tkl/tkldev but tkl/turnkey-tkldev-17.2-bullseye-amd64 in my case.

Running the created container as advised in the readme also crashes:

$ docker run -it --name tkldev --cap-add=SYS_ADMIN -v ~/products:/turnkey/fab/products --tmpfs /tmp --tmpfs /run --tmpfs /run/lock -v /sys/fs/cgroup:/sys/fs/cgroup tkl/turnkey-tkldev-17.2-bullseye-amd64
Failed to set up the root directory for shared mount propagation: Permission denied
systemd 247.3-7+deb11u1 running in system mode. (+PAM +AUDIT +SELINUX +IMA +APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +ZSTD +SECCOMP +BLKID +ELFUTILS +KMOD +IDN2 -IDN +PCRE2 default-hierarchy=unified)
Detected architecture x86-64.
Set hostname to <cf2b899ce267>.
Failed to create /init.scope control group: No such file or directory
Failed to allocate manager object: No such file or directory
[!!!!!!] Failed to allocate manager object.
Freezing execution.
derMart commented 1 year ago

oh wait, despite the critical errors in the console output I can bash exec into the container... Still, those error messages don't make me comfortable that the container is actually working as intended...

JedMeister commented 1 year ago

Thanks for your feedback. FWIW this is an internal tool which was developed by @a3s7p and AFAIK mostly (only) used by him too for local TurnKey development.

Personally I run TKLDev in a KVM VM and we do our official builds on an AWS instance running TKLDev.

As it's an internal tool that I haven't used I can't really offer any support for it. (I hope to give it a run one day, but I have so many things on my backlog that I have no idea when that might be).

derMart commented 1 year ago

Thanks alot for your answer. As you might have recognized in the other issue, I didn't get that to work. There were errors running fab, which related to mounting (as read only overlay). So I stopped that path and just used the iso as virtualbox VM. Still, from a developer point of view it would be super beneficial to have tkldev as docker container. I saw that you already published that a few years ago: https://hub.docker.com/r/turnkeylinux/tkldev Just as feedback: Would be awesome to get that updated to current version. And if I could dream a little, it would be even nicer to be able to bash / ssh into that container as a different user than root, ideally somehow being able to specify the UID (e.g. as ENV variable), such that volume mount permission could be synchronized with the host os ;-) as this is always a pain in docker otherwise.

a3s7p commented 1 year ago

thanks for your feedback @derMart, i did not expect someone to start using this :slightly_smiling_face:

i should probably add a disclaimer to the README that this is not intended for general purpose use just yet

it works for me but so far i think nobody else got it to work for them (it is fairly environment-sensitive as it mounts the host cgroup hierarchy to the container and systemd really doesn't like running in a container anyway)

the reason you need sudo is that otherwise you cannot extract the root-owned files as root-owned, which is important so the docker-imported filesystem has correct ownership

i'm aware of the isoinfo filename weirdness, but haven't gotten around to fixing it yet

in the meantime please use the iso in a VM or on bare metal which is a supported / mainstream way to run tkldev.

derMart commented 1 year ago

Thanks alot for the explanation. One thing is left for me: https://hub.docker.com/r/turnkeylinux/tkldev seemed to work, but I haven't found the sources of those docker images. Are the docker-compose or Dockerfiles of those available somewhere, or could you publish them? Could be a good starting point to get them updated :-)

JedMeister commented 1 year ago

Hi @derMart. Our "official" Docker builds are a hack (that predates docker-compose) - AFAIK somewhat similar to what Anton has done with this dockerize.sh script - but with more moving parts. They are generated (from the ISO file) by our bt-docker script.

The Docker builds haven't been updated for quite a while now, so they're pretty old and TBH I wouldn't recommend using them (especially the TKLDev one - because that's really old! Core and many others aren't quite so old but still outdated). TBH, I don't exactly recall why we stopped building them but I vaguely recall some issues and I never circled back to investigate. We've had very little feedback about the lack of up to date images, so it's never risen high enough in the priorities to get any attention.

If you want to try the bt-docker script, you'll need to install TKLDev into a "proper" VM and cd to the buildtasks directory (i.e. cd buildtasks) and create the required config: cp -r config.example config and tweak the config. Then run bt-container tkldev-17.2-bullseye-amd64. I have no idea if it will work or not or even if it does work, whether the resultant container will work.

So bottom line, I'm not convinced that going that way is a solution here (and will require work that is also required currently and is essentially a sidetrack). Although having said that, if you can get it working, then I'd be happy to start pushing Docker builds to Docker Hub again.