How to Install Containerd on Fedora 36 / Fedora 35

containerd is an industry-standard container runtime that manages the container lifecycle. It handles image transfer and storage, container execution and supervision, low-level storage and network attachments, etc.

containerd is one of the container runtimes that works with Kubernetes, and it is well suited for your environment due to its simplicity.

Here, we will see how to install containerd on Fedora 36 / Fedora 35.

Install Containerd on Fedora

You can install containerd using official binaries or from the Docker repository.

Install Containerd Using Official Binaries

Install Containerd

First, download the latest version of containerd binary from GitHub and extract the files to the /usr/local/ directory.

wget https://github.com/containerd/containerd/releases/download/v1.6.6/containerd-1.6.6-linux-amd64.tar.gz

sudo tar Czxvf /usr/local containerd-1.6.6-linux-amd64.tar.gz

Then, download the systemd service file and set it up so you can manage the service via systemd.

wget https://raw.githubusercontent.com/containerd/containerd/main/containerd.service

sudo mv containerd.service /usr/lib/systemd/system/

sudo restorecon -Rv /usr/lib/systemd/system/

Finally, start the containerd service using the below command.

sudo systemctl daemon-reload

sudo systemctl enable --now containerd

Install runC

runC is a CLI tool for spawning and running containers on Linux according to the OCI specification.

Download the latest version of runC from GitHub and install it as /usr/local/sbin/runc.

wget https://github.com/opencontainers/runc/releases/download/v1.1.3/runc.amd64

sudo install -m 755 runc.amd64 /usr/local/sbin/runc

Containerd configuration for Kubernetes

containerd uses a configuration file config.toml for handling its demons. When installing containerd via official binaries, you will not get the configuration file. So, generate the default configuration file using the below commands.

sudo mkdir -p /etc/containerd/

containerd config default | sudo tee /etc/containerd/config.toml

If you plan to use containerd as the runtime for Kubernetes, configure the systemd cgroup driver for runC.

sudo sed -i 's/SystemdCgroup \= false/SystemdCgroup \= true/g' /etc/containerd/config.toml

Next, use the below command to restart the containerd service.

sudo systemctl restart containerd

Using Docker Repository

Docker offers the containerd containerd.io package in the .deb format through the Docker repository. So, install the required packages for containerd installation.

Set up Docker Repository

Add the Docker repository to the system by running the below command.

sudo dnf -y install dnf-plugins-core

sudo dnf config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo

Install Containerd

Then, install containerd using the dnf command.

sudo dnf install -y containerd.io

Next, start the containerd service

sudo systemctl enable --now containerd

Then, check the status of the containerd service.

sudo systemctl status containerd

Containerd configuration for Kubernetes

containerd uses a configuration file config.toml for managing demons. For Kubernetes, you need to configure the Systemd group driver for runC.

cat <<EOF | sudo tee -a /etc/containerd/config.toml
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc]
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc.options]
SystemdCgroup = true
EOF

Then, enable CRI plugins by commenting out disabled_plugins = ["cri"] in the config.toml file.

sudo sed -i 's/^disabled_plugins \=/\#disabled_plugins \=/g' /etc/containerd/config.toml

Next, use the below commands to restart the containerd service.

sudo systemctl restart containerd

Install CNI Plugins For Containerd / Kubernetes

For the container to run, you need to install CNI plugins. In Fedora, CNI plugins get installed in the /usr/libexec/cni directory by default; this location is not a standard for CNI plugins. So, make a symbolic link to the standard CNI directory /opt/cni/bin.

sudo dnf install -y containernetworking-plugins

sudo mkdir /opt/cni && sudo ln -sf /usr/libexec/cni/ /opt/cni/bin

Next, restart the containerd service.

sudo systemctl restart containerd

Then, check the status of the containerd service.

sudo systemctl status containerd

Output:

 containerd.service - containerd container runtime
     Loaded: loaded (/usr/lib/systemd/system/containerd.service; enabled; vendor preset: disabled)
     Active: active (running) since Sun 2022-07-24 01:44:29 EDT; 5min ago
       Docs: https://containerd.io
    Process: 771 ExecStartPre=/sbin/modprobe overlay (code=exited, status=0/SUCCESS)
   Main PID: 777 (containerd)
      Tasks: 8
     Memory: 76.1M
        CPU: 144ms
     CGroup: /system.slice/containerd.service
             └─ 777 /usr/local/bin/containerd

Jul 24 01:44:29 fedora.itzgeek.local containerd[777]: time="2022-07-24T01:44:29.349868141-04:00" level=info msg=servin>
Jul 24 01:44:29 fedora.itzgeek.local containerd[777]: time="2022-07-24T01:44:29.349938386-04:00" level=info msg=servin>
Jul 24 01:44:29 fedora.itzgeek.local containerd[777]: time="2022-07-24T01:44:29.350046585-04:00" level=info msg="conta>
Jul 24 01:44:29 fedora.itzgeek.local systemd[1]: Started containerd.service - containerd container runtime.

Install nerdctl (CLI)

nerdctl is a Docker-compliant command-line interface for containerd. It is not part of the core package, and you may install the latest version of nerdctl from GitHub.

wget https://github.com/containerd/nerdctl/releases/download/v0.21.0/nerdctl-0.21.0-linux-amd64.tar.gz

sudo tar Cxzvf /usr/local/bin nerdctl-0.21.0-linux-amd64.tar.gz

A sample command:

sudo nerdctl run -d -p 80:80 --name=nginx nginx

Conclusion

That’s All. I hope you have learned how to install containerd on Fedora 36 / Fedora 35.

containerddockerfedora 35fedora 36kubernetesnerdctlrunc
Comments (0)
Add Comment