stencila/dockta

feature: mount any '/nix/store' from host machine

Opened this issue · 2 comments

Currently, when executing a Nix based docker container we mount a Nix store volume: https://github.com/stencila/dockter/blob/e8563580a1104f58e9d29e37bc8e4d6dc2a81db4/src/cli-nix.ts#L65-L68

Instead of looking for, and creating if necessary, a Docker volume with the name nix-store, why not look for, and create if necessary, a /nix/store directory on the host machine? Or maybe fall back to the current approach only if there is no /nix/store directory on the host machine.

I've thought of it an can still implement this approach, but ended up going for the Docker data volume approach for its benefits:

Volumes have several advantages over bind mounts:

  • Volumes are easier to back up or migrate than bind mounts.
  • You can manage volumes using Docker CLI commands or the Docker API.
  • Volumes work on both Linux and Windows containers.
  • Volumes can be more safely shared among multiple containers.
  • Volume drivers let you store volumes on remote hosts or cloud providers, to encrypt the contents of volumes, or to add other functionality.
  • New volumes can have their content pre-populated by a container.

In our particular case, I think the first benefit might be the most important. I can also imagine a scenario where a Mac user might be running Nix on the host (with Mac binaries) and decides to try Dockter and ends up corrupting it's Nix store with Linux binaries (pulled by the Docker guests images).

Also, by default Docker data volumes use the local driver, so if we do docker volume inspect nix-store | grep Mountpoint we can see where the /nix folder is located and access it from outside a container if needed (e.g. to mount or copy it to another remote machine).

Ah right, thanks for the clarification. Let's leave this for now then. I'd like to see how the current approach works out in a Kubernetes cluster using a gcePersistentDisk for the Nix store volume.