Skip to content

Commit 47b2d21

Browse files
committed
[WIP] website: enhance container examples
- Add Rootful mode - Add Podman - Add eStargz Signed-off-by: Akihiro Suda <[email protected]>
1 parent 591ce7e commit 47b2d21

File tree

2 files changed

+113
-29
lines changed

2 files changed

+113
-29
lines changed

website/content/en/docs/examples/_index.md

+5-29
Original file line numberDiff line numberDiff line change
@@ -22,40 +22,16 @@ Specifying `--mount-type=virtiofs` is not necessary here, but it is highly recom
2222
for the best performance and stability.
2323

2424
## Running containers
25-
{{< tabpane text=true >}}
2625

27-
{{% tab header="containerd" %}}
28-
```bash
29-
nerdctl.lima run -d --name nginx -p 127.0.0.1:8080:80 nginx:alpine
30-
```
31-
{{% /tab %}}
32-
33-
{{% tab header="Docker" %}}
34-
```bash
35-
limactl start template://docker
36-
export DOCKER_HOST=$(limactl list docker --format 'unix://{{.Dir}}/sock/docker.sock')
37-
docker run -d --name nginx -p 127.0.0.1:8080:80 nginx:alpine
38-
```
39-
{{% /tab %}}
26+
Lima comes with the built-in integration for [containerd](https://containerd.io) and
27+
[nerdctl](https://github.com/containerd/nerdctl) (contaiNERD CTL):
4028

41-
{{% tab header="Kubernetes" %}}
4229
```bash
43-
limactl start template://k8s
44-
export KUBECONFIG=$(limactl list k8s --format 'unix://{{.Dir}}/copied-from-guest/kubeconfig.yaml')
45-
kubectl apply -f ...
30+
nerdctl.lima run -d --name nginx -p 127.0.0.1:8080:80 nginx:alpine
4631
```
47-
{{% /tab %}}
48-
49-
{{< /tabpane >}}
50-
51-
- <http://127.0.0.1:8080> is accessible from the host, as well as from the VM.
52-
53-
- For the usage of containerd and nerdctl (contaiNERD ctl), visit <https://github.com/containerd/containerd>
54-
and <https://github.com/containerd/nerdctl>.
32+
<http://127.0.0.1:8080> is accessible from the host, as well as from the VM.
5533

56-
- If you have installed Lima by `make install`, the `nerdctl.lima` command is also available as `nerdctl`.
57-
If you have installed Lima by `brew install lima`, you may make an alias (or a symlink) by yourself:
58-
`alias nerdctl=nerdctl.lima`
34+
See also the [Containers](./containers) page for other examples such as using Docker and Kubernetes.
5935

6036
## Advanced configuration
6137

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
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

Comments
 (0)