|
| 1 | +--- |
| 2 | +title: Containers |
| 3 | +weight: 5 |
| 4 | +--- |
| 5 | + |
| 6 | +## Running containers |
| 7 | +{{< tabpane text=true >}} |
| 8 | + |
| 9 | +{{% tab header="containerd" %}} |
| 10 | +{{< tabpane text=true >}} |
| 11 | +{{% tab header="Rootless" %}} |
| 12 | +```bash |
| 13 | +lima nerdctl run -d --name nginx -p 127.0.0.1:8080:80 nginx:alpine |
| 14 | +``` |
| 15 | + |
| 16 | +or |
| 17 | + |
| 18 | +```bash |
| 19 | +nerdctl.lima run -d --name nginx -p 127.0.0.1:8080:80 nginx:alpine |
| 20 | +``` |
| 21 | +{{% /tab %}} |
| 22 | +{{% tab header="Rootful" %}} |
| 23 | +```bash |
| 24 | +lima sudo systemctl enable --now containerd |
| 25 | +lima sudo nerdctl run -d --name nginx -p 127.0.0.1:8080:80 nginx:alpine |
| 26 | +``` |
| 27 | +{{% /tab %}} |
| 28 | +{{< /tabpane >}} |
| 29 | + |
| 30 | +- For the usage of containerd and nerdctl (contaiNERD ctl), visit <https://github.com/containerd/containerd> |
| 31 | +and <https://github.com/containerd/nerdctl>. |
| 32 | + |
| 33 | +- If you have installed Lima by `make install`, the `nerdctl.lima` command is also available as `nerdctl`. |
| 34 | + If you have installed Lima by `brew install lima`, you may make an alias (or a symlink) by yourself: |
| 35 | + `alias nerdctl=nerdctl.lima` |
| 36 | + |
| 37 | +{{% /tab %}} |
| 38 | + |
| 39 | +{{% tab header="Docker" %}} |
| 40 | +{{< tabpane text=true >}} |
| 41 | +{{% tab header="Rootless" %}} |
| 42 | +```bash |
| 43 | +limactl start template://docker |
| 44 | +export DOCKER_HOST=$(limactl list docker --format 'unix://{{.Dir}}/sock/docker.sock') |
| 45 | +docker run -d --name nginx -p 127.0.0.1:8080:80 nginx:alpine |
| 46 | +``` |
| 47 | +{{% /tab %}} |
| 48 | +{{% tab header="Rootful" %}} |
| 49 | +TBD |
| 50 | +{{% /tab %}} |
| 51 | +{{< /tabpane >}} |
| 52 | +{{% /tab %}} |
| 53 | + |
| 54 | +{{% tab header="Podman" %}} |
| 55 | +{{< tabpane text=true >}} |
| 56 | +{{% tab header="Rootless" %}} |
| 57 | +TBD |
| 58 | +{{% /tab %}} |
| 59 | +{{% tab header="Rootful" %}} |
| 60 | +TBD |
| 61 | +{{% /tab %}} |
| 62 | +{{< /tabpane >}} |
| 63 | +{{% /tab %}} |
| 64 | + |
| 65 | + |
| 66 | +{{% tab header="Kubernetes" %}} |
| 67 | +{{< tabpane text=true >}} |
| 68 | +{{% tab header="kubeadm" %}} |
| 69 | +```bash |
| 70 | +limactl start template://k8s |
| 71 | +export KUBECONFIG=$(limactl list k8s --format 'unix://{{.Dir}}/copied-from-guest/kubeconfig.yaml') |
| 72 | +kubectl apply -f ... |
| 73 | +``` |
| 74 | +{{% /tab %}} |
| 75 | +{{% tab header="k3s" %}} |
| 76 | +TBD |
| 77 | +{{% /tab %}} |
| 78 | +{{< /tabpane >}} |
| 79 | +{{% /tab %}} |
| 80 | + |
| 81 | +{{< /tabpane >}} |
| 82 | + |
| 83 | +- <http://127.0.0.1:8080> is accessible from the host, as well as from the VM. |
| 84 | + |
| 85 | +## Accelerating pulls with eStargz |
| 86 | + |
| 87 | +WIP |
| 88 | + |
| 89 | +```console |
| 90 | + |
| 91 | +$ time nerdctl --snapshotter=overlayfs run -it --rm ghcr.io/stargz-containers/python:3.7-org python3 -c 'print("hi")' |
| 92 | +[...] |
| 93 | +hi |
| 94 | + |
| 95 | +real 0m33.505s |
| 96 | +user 0m2.962s |
| 97 | +sys 0m6.629s |
| 98 | +``` |
| 99 | + |
| 100 | +```console |
| 101 | +$ time nerdctl --snapshotter=stargz run -it --rm ghcr.io/stargz-containers/python:3.7-esgz python3 -c 'print("hi")' |
| 102 | +[...] |
| 103 | +hi |
| 104 | + |
| 105 | +real 0m12.335s |
| 106 | +user 0m0.469s |
| 107 | +sys 0m0.522s |
| 108 | +``` |
0 commit comments