containers / krunvm

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

Help, how to use krunvm to run docker or k3s #30

Closed wtry closed 2 years ago

wtry commented 2 years ago

Thanks for providing such an excellent tool! But I haven't found how to use this tool Using docker on macOS is very complicated. Docker can only be installed in vm, which is very resource-intensive and inefficient. After seeing this tool, I want to create a vm, and then run docker or k3s in the vm, instead of qemu, docker for mac or other virtual machines, but I have no success, no matter it is docker, podman, k3s, can't Started in the image of krunvm, is there any way to use docker or k3s in the image of krunvm?

slp commented 2 years ago

Running regular OCI containers doesn't fit quite well with the microVM model, as they require a context that provides a significant amount of features. For this purpose, podman (which is also available on macOS) is a much better option.

wtry commented 2 years ago

I gave up Can't run docker, k3s and podman

❯ krunvm create --name k3s rancher/k3s:latest -v /Users/lan/Developer:/developer -p 8888:8888 microVM created with name: k3s ❯ krunvm start k3s WARN[0000] failed to move process 2 to cgroup "/init" error="write /sys/fs/cgroup/init/cgroup.procs: invalid argument" WARN[0000] failed to move process 3 to cgroup "/init" error="write /sys/fs/cgroup/init/cgroup.procs: invalid argument" WARN[0000] failed to move process 4 to cgroup "/init" error="write /sys/fs/cgroup/init/cgroup.procs: invalid argument" WARN[0000] failed to move process 5 to cgroup "/init" error="write /sys/fs/cgroup/init/cgroup.procs: invalid argument" WARN[0000] failed to move process 6 to cgroup "/init" error="write /sys/fs/cgroup/init/cgroup.procs: invalid argument" WARN[0000] failed to move process 7 to cgroup "/init" error="write /sys/fs/cgroup/init/cgroup.procs: invalid argument" WARN[0000] failed to move process 8 to cgroup "/init" error="write /sys/fs/cgroup/init/cgroup.procs: invalid argument" WARN[0000] failed to move process 9 to cgroup "/init" error="write /sys/fs/cgroup/init/cgroup.procs: invalid argument" WARN[0000] failed to move process 10 to cgroup "/init" error="write /sys/fs/cgroup/init/cgroup.procs: invalid argument" WARN[0000] failed to move process 12 to cgroup "/init" error="write /sys/fs/cgroup/init/cgroup.procs: invalid argument" WARN[0000] failed to move process 13 to cgroup "/init" error="write /sys/fs/cgroup/init/cgroup.procs: invalid argument" WARN[0000] failed to move process 14 to cgroup "/init" error="write /sys/fs/cgroup/init/cgroup.procs: invalid argument" WARN[0000] failed to move process 15 to cgroup "/init" error="write /sys/fs/cgroup/init/cgroup.procs: invalid argument" WARN[0000] failed to move process 16 to cgroup "/init" error="write /sys/fs/cgroup/init/cgroup.procs: invalid argument" WARN[0000] failed to move process 17 to cgroup "/init" error="write /sys/fs/cgroup/init/cgroup.procs: invalid argument" WARN[0000] failed to move process 18 to cgroup "/init" error="write /sys/fs/cgroup/init/cgroup.procs: invalid argument" WARN[0000] failed to move process 19 to cgroup "/init" error="write /sys/fs/cgroup/init/cgroup.procs: invalid argument" WARN[0000] failed to move process 20 to cgroup "/init" error="write /sys/fs/cgroup/init/cgroup.procs: invalid argument" WARN[0000] failed to move process 21 to cgroup "/init" error="write /sys/fs/cgroup/init/cgroup.procs: invalid argument" WARN[0000] failed to move process 22 to cgroup "/init" error="write /sys/fs/cgroup/init/cgroup.procs: invalid argument" WARN[0000] failed to move process 23 to cgroup "/init" error="write /sys/fs/cgroup/init/cgroup.procs: invalid argument" WARN[0000] failed to move process 24 to cgroup "/init" error="write /sys/fs/cgroup/init/cgroup.procs: invalid argument" WARN[0000] failed to move process 25 to cgroup "/init" error="write /sys/fs/cgroup/init/cgroup.procs: invalid argument" WARN[0000] failed to move process 26 to cgroup "/init" error="write /sys/fs/cgroup/init/cgroup.procs: invalid argument" WARN[0000] failed to move process 27 to cgroup "/init" error="write /sys/fs/cgroup/init/cgroup.procs: invalid argument" WARN[0000] failed to move process 28 to cgroup "/init" error="write /sys/fs/cgroup/init/cgroup.procs: invalid argument" WARN[0000] failed to move process 30 to cgroup "/init" error="write /sys/fs/cgroup/init/cgroup.procs: invalid argument" WARN[0000] failed to move process 31 to cgroup "/init" error="write /sys/fs/cgroup/init/cgroup.procs: invalid argument" WARN[0000] failed to move process 32 to cgroup "/init" error="write /sys/fs/cgroup/init/cgroup.procs: invalid argument" WARN[0000] failed to move process 33 to cgroup "/init" error="write /sys/fs/cgroup/init/cgroup.procs: invalid argument" WARN[0000] failed to move process 34 to cgroup "/init" error="write /sys/fs/cgroup/init/cgroup.procs: invalid argument" WARN[0000] failed to move process 36 to cgroup "/init" error="write /sys/fs/cgroup/init/cgroup.procs: invalid argument" WARN[0000] failed to move process 74 to cgroup "/init" error="write /sys/fs/cgroup/init/cgroup.procs: invalid argument" WARN[0000] failed to move process 75 to cgroup "/init" error="write /sys/fs/cgroup/init/cgroup.procs: invalid argument" WARN[0000] failed to move process 76 to cgroup "/init" error="write /sys/fs/cgroup/init/cgroup.procs: invalid argument" WARN[0000] failed to move process 154 to cgroup "/init" error="write /sys/fs/cgroup/init/cgroup.procs: invalid argument" WARN[0000] failed to move process 155 to cgroup "/init" error="write /sys/fs/cgroup/init/cgroup.procs: invalid argument" WARN[0000] failed to move process 156 to cgroup "/init" error="write /sys/fs/cgroup/init/cgroup.procs: invalid argument" WARN[0000] failed to move process 157 to cgroup "/init" error="write /sys/fs/cgroup/init/cgroup.procs: invalid argument" WARN[0000] failed to move process 208 to cgroup "/init" error="write /sys/fs/cgroup/init/cgroup.procs: invalid argument" WARN[0000] failed to move process 245 to cgroup "/init" error="write /sys/fs/cgroup/init/cgroup.procs: invalid argument" WARN[0000] failed to move process 248 to cgroup "/init" error="write /sys/fs/cgroup/init/cgroup.procs: invalid argument" WARN[0000] failed to move process 249 to cgroup "/init" error="write /sys/fs/cgroup/init/cgroup.procs: invalid argument" WARN[0000] failed to move process 250 to cgroup "/init" error="write /sys/fs/cgroup/init/cgroup.procs: invalid argument" WARN[0000] failed to move process 251 to cgroup "/init" error="write /sys/fs/cgroup/init/cgroup.procs: invalid argument" WARN[0000] failed to move process 252 to cgroup "/init" error="write /sys/fs/cgroup/init/cgroup.procs: invalid argument" WARN[0000] failed to move process 253 to cgroup "/init" error="write /sys/fs/cgroup/init/cgroup.procs: invalid argument" FATA[0000] --token is required

slp commented 2 years ago

I gave up Can't run docker, k3s and podman

* [white_check_mark ] krunvm create --name podman arm64v8/fedora:latest -v /Users/lan/Developer:/developer -p 8888:8888

* [white_check_mark] krunvm start podman

* [white_check_mark] dnf -y install podman

* [white_check_mark] podman info
  `Error: llistxattr /var/lib/containers/storage/overlay: operation not supported`
  add stoage.conflist solved
  `[storage] driver = "overlay" [storage.options] mount_program = "/usr/bin/fuse-overlayfs"`

* [x] podman run hello-world
  `Error: netavark: failed to load network options: No such file or directory (os error 2)`
  add containers.conf solved
  `[containers] netns="host"`

* [x] podman run hello-world
  `` Error: OCI runtime error: crun: bpf create ``: Function not implemented ``

Seems like newer versions of crun need BPF. I've just added support for that on aarch64 (was already enabled in x86_64) in libkrunfw-3.6.0. Should work after updating your packages:

slp@Sergios-MacBook-Air ~ % krunvm start fedora
[root@fedora /]# podman run -ti --rm hello-world
Resolved "hello-world" as an alias (/etc/containers/registries.conf.d/000-shortnames.conf)
Trying to pull quay.io/podman/hello:latest...
Getting image source signatures
Copying blob bb59fa5fb5d2 done  
Copying config ecb9b3e96a done  
Writing manifest to image destination
Storing signatures
!... Hello Podman World ...!

         .--"--.           
       / -     - \         
      / (O)   (O) \        
   ~~~| -=(,Y,)=- |         
    .---. /`  \   |~~      
 ~/  o  o \~~~~.----. ~~   
  | =(X)= |~  / (O (O) \   
   ~~~~~~~  ~| =(Y_)=-  |   
  ~~~~    ~~~|   U      |~~ 

Project:   https://github.com/containers/podman
Website:   https://podman.io
Documents: https://docs.podman.io
Twitter:   @Podman_io

That said, I still think podman-machine is a better option if you intent to mostly run podman commands. Or, alternatively, using krunvm directly with the container you intend to run.