IMO—package manager outside the container. You just want the packages inside the container; the manager can sit outside and install packages into the container.
IMO—package manager outside the container. You just want the packages inside the container; the manager can sit outside and install packages into the container.
Yes, how?
There have got to be a million ways to do this by now. Some of the more principled approaches are tools like Nix (https://xeiaso.net/talks/2024/nix-docker-build/) and Bazel (https://github.com/bazel-contrib/rules_oci). But if you want to use an existing package manager like apt, you can pick it apart. Apt calls dpkg, and dpkg extracts files and runs post-install scripts. Only the post-install script needs to run inside the container.
I may be a little out of touch here, because the last time I did this, we used a wholly custom package manager.
apk and xbps can do this. You specify a different root to work in.
Most Makefiles allow you to specify an alternate DESTDIR on install.