4 ms·
So I was trying to follow along with this and kept getting an error /# chroot /testroot /hello chroot: failed to run command ‘/hello’: No such file or
by patrick451 4y ago
So I was trying to follow along with this and kept getting an error
/# chroot /testroot /hello
chroot: failed to run command ‘/hello’: No such file or directory
If anybody was wondering, the trick is to statically link
gcc hello.c -o hello -static -static-libgcc
Or, use go for the hello executable
- BeefWellington 4y agoOr dynamically link and use ldd to identify and copy libraries the program is linking: ldd hello
- chriswarbo 4y agoThis is why I build containers using Nix (plus the reproducibility, caching, etc.): since everything has a path containing an unguessable hash, all dependencies must be referred to by their absolute path (either directly, or indirectly via an env var, etc.). That makes it trivial to find all the dependencies of a file (whether they're dynamic libraries, interpreter packages, image files, etc.), transitively, and tar them all up into a self-contained container :)
- adamgordonbell 4y agoAuthor here. Sorry, I should have added more instruction there. What I was expecting someone to do is use the 'pull' command made later to extract a statically linked hello from the hello:latest image, but I didn't explain how until later. So yes, thanks for including this, static linked is the way to go here, or ldd and copying other things in.