DEV Community

Cover image for Creating containers with containerd & nerdctl on ARM
Sergio Méndez
Sergio Méndez

Posted on

Creating containers with containerd & nerdctl on ARM

Hi Folks, this is the Day 2 of my series 30DaysOfIoTEdge. Its time to learn more in deep how to create containers with a lightweight container runtime containerd together with nerdctl to create containers. nerdctl provides to the users to interact with the containerd to create containers as same as Docker.

containerd provides similar functionalities like Docker but in a small memory and CPU footprint which is ideal for IoT or edge solutions when using containers, also we are using ARM microprocessor that has a good balance between energy and CPU consumption, so that's the reason about why containerd fits and match nicely with ARM.

Also, Containers are the tool when you want to speed your process of updating your software and get modularity and portability when deploying your solutions. In this post you will learn how containerd together with nerdctl can help you with this use case scenario. Check their official websites for more info https://containerd.io and https://github.com/containerd/nerdctl.

What you will learn

In this blog post you will learn:

  • Install the containerd container runtime on ARM Devices (Rasberry Pi).
  • Install nerdctl to use containerd to create containers.
  • Create a basic container with nerdctl command line.

Requirements

  • Raspberry Pi or ARM instance in the cloud.
  • Ubuntu >= 22.04
  • Install containerd
  • Install CNI plugin
  • Install nerdctl

So Let's create containers with containerd.

Creating Python containers for ARM

1. Install containerd running the following command:

sudo apt-get update
sudo apt-get install -y containerd
Enter fullscreen mode Exit fullscreen mode

This commands install containerd in your device.

2. Install nerdctl with the following commands:

NERDCTL_VERSION=2.0.3
wget https://github.com/containerd/nerdctl/releases/download/v2.0.3/nerdctl-$NERDCTL_VERSION-linux-arm64.tar.gz 
tar -xzvf nerdctl-$NERDCTL_VERSION-linux-arm64.tar.gz -C /sbin
CNI_VERSION
wget https://github.com/containernetworking/plugins/releases/download/v1.6.2/cni-plugins-linux-arm64-vCNI_VERSION.tgz
mkdir -p /opt/cni/bin
tar -xzvf cni-plugins-linux-arm64-vCNI_VERSION.tgz -C /opt/cni/bin

Enter fullscreen mode Exit fullscreen mode

3. Create a container with nerdctl
Create an NGINX container exposing the port 80 to the 8080 in the host:

sudo nerdctl run --restart always -d -p 80:80 --name=nginx nginx
Enter fullscreen mode Exit fullscreen mode

4. Test the container
Create the file with the following command:

curl localhost:8080
Enter fullscreen mode Exit fullscreen mode

Note: This returns It works.

Extra commands

You can use the following commands for containerd:
1. To restart the service run:

sudo systemctl restart containerd
Enter fullscreen mode Exit fullscreen mode

You can use the following commands for nerdctl:
2. List images

sudo nerdctl images
Enter fullscreen mode Exit fullscreen mode

3. Push images

sudo nerdctl images
Enter fullscreen mode Exit fullscreen mode

4. Pull images

sudo nerdctl images
Enter fullscreen mode Exit fullscreen mode

5. Build images in the current directory

sudo nerdctl build . 
Enter fullscreen mode Exit fullscreen mode

6. Tag images

sudo nerdctl tag old_image:old_tag new_image:new_tag
Enter fullscreen mode Exit fullscreen mode

Where is Podman, Docker and CRI-O?

Wait a moment. Let me tell you that there are alternatives, but containerd in particular has a low memory and CPU footprint so it's ideal for IoT and Edge devices. Podman could fit these needs and interact directly with RunC, which is daemonless. Docker because has more options and its daemon consumes more resources maybe doesn't fit IoT needs. CRI-O it could be but was designed to be lightweight and fit OCI compliance. Also, ask yourself if you need ARM support. The final decision depends on how much energy you want to consume, features, etc. With containerd, you can go wrong with IoT and Edge. In the future, I will add some table of comparison about footprint consumption. But try this tutorial to see how containerd performs.

Thank you and follow me

If you liked my blog post comment 😀
Also follow me at:

This blog post is an extended version of my book:

Top comments (0)