Preface

This is a series of notes during my preparation for a DevOps interview. I asked Gemini a bunch of questions back and forth based on my understanding and relative background. I am the one who edits and produces the end result. However, I haven’t fully verify the correctness of all the details and thus the content can be misleading.

Python

  • Scope: manage python packages under site-packages/.
  • Tools:
    • pip with requirements.txt or pyrpoject.toml.
    • uv with uv.lock.
  • Limitation: only manages python packages. Since python is considered as a glue language and a lot of the underlying code is in other languages, e.g., C or CUDA, managing python dependencies does not guarantee bit-by-bit perfection.

Conda

  • Scope: manages both python packages and layer 2 (C-libraries).
    • Can install cuda-toolkit or libgcc without requiring sudo.
  • Tools:
    • conda / miniconda
    • mamba / micromamba
  • Limitation: borrows the core C library (glibc) and the dynamic loader from the host OS.

Nix

NOTE

I included Nix because I was interested in Nix and NixOS and the declarative approach. However, my personal experience of running NixOS on my laptop is both interesting and suffering. Skill issue I suppose.

  • A declarative, functional tool to define inputs (dependencies) and build immutable, identical environments.
  • Scope: above the Linux kernel, alongside the filesystem.
    • It mostly ignores the standard paths, however. It uses its own packages from /nix/store.
  • Tools:
    • nix-shell
    • nix-develop
    • flake.nix with flake.lock
  • Limitation
    • Non FHS-compliant: doesn’t utilize standard or hard-coded paths. Precompiled binaries and global states won’t work. Everything needs to be explicitly declared.
    • Steep learning curve & ecosystem barrier. Not the industry standard.
    • Still dependent on the host Linux kernel. If the code uses some brand-new feature of Linux kernel, the program running on an older one will crash.

Container

  • Imperatively builds the environment. Takes snapshots of every layer.
  • Scope: above the Linux kernel.
    • Compared to Nix, containers bring their own isolated filesystem.
  • Tools:
    • docker
    • podman
  • Limitation
    • Container still depend on the host Linux Kernel and hardware drivers.
    • Since it captures the entire OS, containers can take more space than Nix environments.
    • Container builds are not always consistent, e.g. apt update might lead to differences between images built in different times.

Virtual Machine

  • Hosts the OS, core libraries (glibc), C libraries, and language-specific packages.
  • Sits on top of the hypervisor. The hypervisor acts as an abstract layer of the underlying hardware and exposes a generic virtual hardware to the VM.
  • Scope: almost everything.
  • Tools:
    • VirtualBox
    • VMWare
    • Hyper-V
  • Limitation: resource-intensive, higher overhead, lower portability (?)

Comparisons

Different Layers of Environment/Dependency Management

LayerComponentManaged by
3. LanguagePython, PyTorch, NumPypip, uv, conda
2. DistributionCUDA, C++ libraires (BLAS), Compilersconda, nix
1. OS CoreKernel, glibc (Core C library), DriversDocker, NixOS
ComponentStandard AppNix FlakeContainerVM
Libraries (glibc)HostBrings its ownBrings its ownBrings its own
File system (/)HostHostBrings its ownBrings its own
KernelHostHostShared host kernelBrings its own
LayerComponentStandard AppNix FlakeContainer (Docker)Virtual Machine
3. ApplicationPython, PyTorch, NumPyHost / pipBrings its ownBrings its ownBrings its own
2. DistributionC++ / CUDA / BLASHost / aptBrings its ownBrings its ownBrings its own
1.5 Core Libsglibc (The C Library)HostBrings its ownBrings its ownBrings its own
1. OS CoreRoot FS (/etc, /var)HostHostBrings its ownBrings its own
0.5 HardwareKernel Drivers (NVIDIA)HostHostShared HostBrings its own*
0. KernelThe Linux KernelHostHostShared HostBrings its own

Comparison between Environment Management Technologies

TechnologyIsolation LevelPrimary FocusShared w/ HostReproducibilityWhere it Fails
uv/pipLanguagePython versions & packagesEverything except python site-packagesMedium, depends on host OS/C-libs.System libraries (.so files)
CondaUser-spacePython + non-Python binary dependencies (CUDA, C++)Host kernel and core C-library (glibc)High, but fails across vastly different OS versions.Core OS libraries (glibc)
NixLogical/PureEntire dependency graphHost kernelExtreme, highest logical guaranteeStandard paths (precompiled binaries)
ContainerOS FilesystemThe entire root filesystem (user-space)Host kernel onlyVery high, the industry standard for portabilityKernel version & hardware drivers
VMHardwareThe entire machine, including the OS kernelPhysical hardware via HypervisorTotal, can run a different kernel entirelyPhysical CPU instructions

Container vs. Nix

FeatureContainerNix
PhilosophySnapshottingFunctional
StorageLayers: a stack of filesystem changesStore: a flat collection of unique, hashed packages
MutationMutable during buildImmutable
CompatibilityHigh: runs almost any Linux software out-of-the-boxLow due to not FHS compliant
EfficiencyMedium: images include a full OSHigh: only installs exactly what’s needed