As a scientific software developer exploring GPUs, and particularly, the fast-moving ROCm ecosystem for AMD, as well as Vulkan, I'm frequently loading and testing new cutting-edge libraries, many of which are complicated and sometimes unstable. I don't want to clutter up my "base" system with all these installs, some of which may do stuff that hurts other bits of the system. I also frequently need to uninstall and reinstall. This problem is well known in Python development where the "virtual environment" (aka virtualenv) system has been developed, allowing custom "pip" environments with different package versions and even python versions inside them. So my question is:
Is a python-style virtualenv possible on Linux, and in particular, Ubuntu, which allows for apt (or snap or flatpak or indeed, source-based) installations that are sealed off from the base system?
Like Python virtualenvs, it would have to meet the following criteria:
a) All the base system packages should be visible from inside the "virtualenv".
b) Anything installed within the "virtualenv" should not be able to affect anything outside.
c) When I delete the virtualenv, it should remove all traces of itself and anything I've ever done inside it regarding software installations.
d) All the hardware must be visible, including GPU(s).
e) not necessary: different Linux kernel versions analogous to different python versions which virtualenvs allow.
I realise that there may be file-level problems with point c) because if you create files and directories in a python-level virtualenv, they'll remain afterwards. So source-based package installations may be problematic in this regard but I'm willing to be flexible on this front.
One technology which I don't want to use is virtualization. This does not meet criterion a) above and frequently doesn't meet d). My "base" system is already quite complex with frequently used things and I don't want to have to reinstall them each time. Grub-based multiple OS partitions also doesn't meet criterion a).
Can docker do this? I've never been able to figure out how to create a kind of "bash command line" within a container that I can then start installing stuff into which is then sealed off nicely. Do I have to go through a trial-and-error "docker compose" style workflow to meet this objective?
What about KVM, Snap, flatpak, or even lower level, cgroups? Some kind of file-system-level technology perhaps like ZFS or btrfs?
What are my options?
To behave even more like "a usual ubuntu system" instead of Docker I'd think you could consider LXD containers.
A docker container wouldn't satisfy: