Containerd - What is Containerd?

Containerd is a high-level core container runtime that Docker created. It was donated to CNCF later. It pulls images from registries, mounts storage, and creates container networking. It is a daemon process that starts, stops, and kills containers. Thus, it manages the lifecycle of containers. Software projects can use this to run containers and manage container images.


It has most of Docker’s functionality for managing containers and images, which makes it suitable for large-scale use as part of container orchestrators like Kubernetes(k8s).


Containerd follows and supports OCI standards. It also supports Container Runtime Interface (CRI), a Kubernetes(k8s) specification, which helps run multiple container runtimes in a cluster.

containerd-what-is-containerd

Installation of Containerd

containerd installation comes with the following downstream dependencies:


runC - to run containers


ctr - A CLI for containerd


containerd-shim - to support daemonless (containers can either be run as root or in rootless mode) containers


Install containerd on Ubuntu system with use of apt as follows:


apt update && apt install -y containerd

Now, confirm the installation by running the following command:


containerd --help


Managing Containerd

Run the following command to check the status of containerd service.


systemctl status containerd


Containerd - Command Line

Containerd contains a command-line tool ctr that can issue commands against containerd daemon. To get started, we can look over the available ctr commands:


ctl --help


Containerd - Image Operations


containerd-what-is-containerd

Pull a image — ctr images pull docker.io/library/nginx:latest


List out images — ctr images ls


Delete the images — ctr images rm docker.io/library/golang:latest



Containerd - Container Operations


Create a container — ctr container create docker.io/library/nginx:latest nginx_ctr


List out containers — ctr containers ls


Run a container — ctr task start nginx_ctr


List tasks — ctr task ls


Create and Start container — ctr run -d docker.io/library/nginx:latest nginx_web


Interact with container — ctr task exec -t --exec-id bash_1 nginx_web bash


Usage metrics by the task — ctr task metrics nginx_web


Stop the task — ctr task kill nginx_web


Remove the container — ctr container rm nginx_web



Summary and Conclusions


We have seen the most widely used container runtime interface, containerd, its installation, and how to work with container images and containers using ctr.



Author


sagar-mehta

Sagar Mehta is Atgen Software Solutions Founder and a recognised expert in the field of Intelligent Automation, including Robotic Process Automation, Workload Automation, DevOps, SRE and Advanced Analytics. Sagar advocates a pragmatic approach to Automation, encouraging a policy of using ‘the best tool for the job’.


Prior to co-founding Atgen Software Solutions, Sagar worked in Senior Automation roles, architecting and delivering robust, scalable solutions for many of the world’s biggest banks and working with leading Automation vendors. He developed his first automated solution in 2006 and has continued to deliver robust, scalable and sophisticated Automation ever since.


Sagar is a regular guest speaker and panellist at Automation seminars, conferences and user group events.

Contact

Have a similar problem to solve, let's work together.

Our Address

#107, Tower B, Escon Arena, Zirakpur, Punjab, India - 140603

Email Us

info@atgensoft.com

Call Us

+91-8806666141