Skip to content

Commit 0ad9cca

Browse files
committed
New install guide for nerdctl and containerd
1 parent 9b02953 commit 0ad9cca

File tree

1 file changed

+147
-17
lines changed

1 file changed

+147
-17
lines changed

content/install-guides/nerdctl.md

Lines changed: 147 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ draft: true
66

77
minutes_to_complete: 10
88

9-
official_docs: https://github.com/containerd/nerdctl
9+
official_docs: https://github.com/containerd/nerdctl/blob/main/docs/command-reference.md
1010

1111
additional_search_terms:
1212
- container
@@ -25,15 +25,17 @@ multitool_install_part: false
2525
weight: 1
2626
---
2727

28-
Nerdctl is an open-source command-line interface (CLI) designed to be compatible with the popular Docker CLI, but specifically for interacting with [containerd](https://containerd.io/). It provides a familiar user experience for developers operators who are familiar with Docker, while leveraging the capabilities of containerd as the underlying container runtime.
28+
[Nerdctl](https://github.com/containerd/nerdctl) is an open-source command-line interface (CLI) designed to be compatible with the Docker CLI, but specifically for interacting with [containerd](https://containerd.io/). It provides a familiar user experience for developers who are familiar with Docker, while leveraging the capabilities of containerd as the underlying container runtime.
2929

30-
Using containerd and nerdctl provides similar functionality to Docker but with a smaller memory and CPU footprint, making it ideal for IoT or edge solutions, especially on Arm devices which balance energy efficiency and performance. Nerdctl also supports running containers in a rootless mode, enhancing security by not requiring elevated privileges.
30+
Using containerd and nerdctl provides similar functionality to Docker but with a smaller memory footprint, making it ideal for IoT and edge solutions, especially on Arm devices that balance energy efficiency and performance.
3131

32-
This guide focuses on installing containerd and Nerdctl on Arm Linux.
32+
Nerdctl also supports running containers in rootless mode, which helps enhance security by not requiring elevated privileges. Rootless mode is not covered below but you can refer to the [documentation](https://rootlesscontaine.rs/getting-started/containerd/) for information about how to run `containerd-rootless-setuptool.sh install`.
33+
34+
This guide explains how to install and use containerd and nerdctl on Arm Linux and run with `sudo`
3335

3436
## Before you begin
3537

36-
This guide assumes you are using Ubuntu 22.04 or later on an Arm-based system (like a Raspberry Pi or an Arm instance in the cloud).
38+
This guide assumes you are using a Debian-based Arm Linux distribution, including Ubuntu and Raspberry Pi OS. You can use a local Arm Linux computer or an Arm instance in the cloud.
3739

3840
Confirm you are using an Arm machine by running:
3941

@@ -47,7 +49,7 @@ The output should be:
4749
aarch64
4850
```
4951

50-
Ensure `wget` and `tar` are installed:
52+
Ensure `wget` and `tar` are installed. Most distributions will include them, but if not run:
5153

5254
```bash
5355
sudo apt-get update
@@ -59,8 +61,7 @@ sudo apt-get install -y wget tar
5961
Install the containerd runtime:
6062

6163
```bash
62-
sudo apt-get update
63-
sudo apt-get install -y containerd
64+
sudo apt-get install containerd -y
6465
```
6566

6667
Start and enable the containerd service:
@@ -70,9 +71,30 @@ sudo systemctl start containerd
7071
sudo systemctl enable containerd
7172
```
7273

74+
Confirm the service is running:
75+
76+
```console
77+
systemctl status containerd.service
78+
```
79+
80+
When containerd is running, the output is similar to:
81+
82+
```output
83+
● containerd.service - containerd container runtime
84+
Loaded: loaded (/usr/lib/systemd/system/containerd.service; enabled; preset: enabled)
85+
Active: active (running) since Tue 2025-04-22 20:12:03 UTC; 2min 20s ago
86+
Docs: https://containerd.io
87+
Main PID: 8428 (containerd)
88+
Tasks: 9
89+
Memory: 13.0M (peak: 13.7M)
90+
CPU: 401ms
91+
CGroup: /system.slice/containerd.service
92+
└─8428 /usr/bin/containerd
93+
```
94+
7395
## Install nerdctl and CNI plugins
7496

75-
Install nerdctl and the necessary CNI (Container Network Interface) plugins. Replace version numbers if needed.
97+
Install nerdctl and the necessary CNI (Container Network Interface) plugins.
7698

7799
```bash
78100
NERDCTL_VERSION=$(curl -s https://api.github.com/repos/containerd/nerdctl/releases/latest | grep tag_name | cut -d '"' -f 4 | sed 's/v//')
@@ -95,35 +117,131 @@ Clean up the downloaded files:
95117
rm nerdctl-${NERDCTL_VERSION}-linux-arm64.tar.gz cni-plugins-linux-arm64-v${CNI_VERSION}.tgz
96118
```
97119

98-
99120
{{% notice Note %}}
100-
The commands above attempt to fetch the latest versions automatically. You can replace `${NERDCTL_VERSION}` and `${CNI_VERSION}` with specific versions if required.*
101-
{{% /notice %}
121+
The commands above attempt to fetch the latest versions automatically. If required, you can replace `${NERDCTL_VERSION}` and `${CNI_VERSION}` with specific versions.
122+
{{% /notice %}}
123+
124+
## Install BuildKit
125+
126+
If you want to build container images with nerdctl, you need to install [BuildKit](https://github.com/moby/buildkit).
127+
128+
If you only need to run container images you can skip this step.
129+
130+
```bash
131+
BUILDKIT_VERSION=$(curl -s https://api.github.com/repos/moby/buildkit/releases/latest | grep tag_name | cut -d '"' -f 4 | sed 's/v//')
132+
wget https://github.com/moby/buildkit/releases/download/v${BUILDKIT_VERSION}/buildkit-v${BUILDKIT_VERSION}.linux-arm64.tar.gz
133+
sudo tar -xzvf buildkit-v${BUILDKIT_VERSION}.linux-arm64.tar.gz -C /usr
134+
rm buildkit-v${BUILDKIT_VERSION}.linux-arm64.tar.gz
135+
```
136+
137+
Create a systemd service for BuildKit:
138+
139+
```bash
140+
sudo tee /etc/systemd/system/buildkit.service > /dev/null << EOF
141+
[Unit]
142+
Description=BuildKit
143+
Documentation=https://github.com/moby/buildkit
144+
145+
[Service]
146+
ExecStart=/usr/bin/buildkitd --oci-worker=false --containerd-worker=true
147+
148+
[Install]
149+
WantedBy=multi-user.target
150+
EOF
151+
```
152+
153+
Start and enable the BuildKit service:
154+
155+
```bash
156+
sudo systemctl daemon-reload
157+
sudo systemctl start buildkit
158+
sudo systemctl enable buildkit
159+
```
160+
161+
Verify BuildKit is running:
162+
163+
```console
164+
sudo systemctl status buildkit
165+
```
166+
167+
When running, the output is similar to:
168+
169+
```output
170+
ubuntu@m1u:~$ sudo systemctl status buildkit
171+
● buildkit.service - BuildKit
172+
Loaded: loaded (/etc/systemd/system/buildkit.service; enabled; preset: enabled)
173+
Active: active (running) since Tue 2025-04-22 22:55:39 CDT; 18min ago
174+
Docs: https://github.com/moby/buildkit
175+
Main PID: 22280 (buildkitd)
176+
Tasks: 10 (limit: 4598)
177+
Memory: 14.6M (peak: 42.0M)
178+
CPU: 1.144s
179+
CGroup: /system.slice/buildkit.service
180+
└─22280 /usr/bin/buildkitd --oci-worker=false --containerd-worker=true
181+
```
182+
183+
Check that buildctl can communicate with the daemon:
184+
185+
```console
186+
sudo buildctl debug workers
187+
```
188+
189+
If BuildKit is properly installed, you should see output similar to:
190+
191+
```output
192+
ID PLATFORMS
193+
jz1h9gb0xq39ob6868cr3ev6r linux/arm64
194+
```
102195

103196
## Verify the installation
104197

105-
Test your installation by running a simple NGINX container:
198+
You can check the nerdctl version:
199+
200+
```console
201+
sudo nerdctl version
202+
```
203+
204+
Test your installation by running a simple container that prints the processor architecture:
106205

107206
```console
108207
sudo nerdctl run --name uname armswdev/uname
109208
```
110209

111-
Wait a few seconds for the container to run, and the Architecture is printed:
210+
Wait a few seconds for the container to start. The architecture is printed:
112211

113212
```output
114213
Architecture is aarch64
115214
```
116215

117-
118216
Clean up the test container:
119217

120218
```console
121219
sudo nerdctl rm uname
122220
```
123221

124-
You can also check the nerdctl version:
222+
To build a container image, use a text editor to copy the lines below to a new file named `Dockerfile`.
223+
125224
```console
126-
sudo nerdctl version
225+
FROM ubuntu:latest
226+
CMD echo -n "Architecture is " && uname -m
227+
```
228+
229+
Build the container image:
230+
231+
```console
232+
sudo nerdctl build -t uname -f Dockerfile .
233+
```
234+
235+
Run the new container image:
236+
237+
```console
238+
sudo nerdctl run uname
239+
```
240+
241+
The output is the architecture:
242+
243+
```output
244+
Architecture is aarch64
127245
```
128246

129247
## Basic nerdctl commands
@@ -178,4 +296,16 @@ Remove a container:
178296
sudo nerdctl rm <container_name_or_id>
179297
```
180298

299+
View container logs:
300+
301+
```console
302+
sudo nerdctl logs <container_name_or_id>
303+
```
304+
305+
Execute a command in a running container:
306+
307+
```console
308+
sudo nerdctl exec -it <container_name_or_id> <command>
309+
```
310+
181311
You are now ready to use nerdctl and containerd.

0 commit comments

Comments
 (0)