containers / krunvm

Create microVMs from OCI images
Apache License 2.0
1.41k stars 42 forks source link

`nixos/nix` docker image won't start #16

Closed stephenjudkins closed 2 years ago

stephenjudkins commented 2 years ago
$ krunvm create --name nix nixos/nix
microVM created with name: nix
$ krunvm start nix      
mount(/proc): No such file or directory

I'm not sure where the problem is here, but I'd be willing to help debug if necessary.

slp commented 2 years ago

Seems like the nixos/nix OCI image does things is pretty different way than most other images, making it incompatible with krunvm. I've identified three issues:

  1. Doesn't contain the directories /proc, /sys, /dev.
  2. Requires some specific environment variables to be set up.
  3. Requires an entry point different than /bin/sh (in the image I've inspected, it needs to be /root/.nix-profile/bin/bash).

For (1), we can modify libkrun's init/init.c to create those directories if they're missing. For (2) and (3), we need to extend krunvm to capture the container entry point and environment variables (buildah inspect gives us this info) and store it along with the other microVM config.

I'll try to get all three fixed in the next version.

stephenjudkins commented 2 years ago

Awesome. Thanks for the update.

slp commented 2 years ago

nixos/nix should work fine with krunvm 0.2.1 and libkrun 1.3.0. It takes a while to create the microVM because the OCI image is composed by a large number of layers, but otherwise I was able to start the microVM and use nix-shell to install vim. Please let me know if the problem persists.

stephenjudkins commented 2 years ago

Confirmed that the image starts and works! Thank you.

I have found another issue that seems pretty hard to nail down regarding file permissions, however... might file another bug once I minimize it