Brief description of containerd in docker modify the default path of containerd directory

Brief description of containerd

containerd is a container virtualization technology, which is separated from docker and forms a part of the open container interface (OCI) standard.

docker basically manages and operates containers through Containerd. Container is an industrial standard container runtime, which emphasizes simplicity, robustness and portability. Container can manage the complete container life cycle in the host: the transmission and storage of container image, the execution and management of container, storage and network, etc. To be more specific, container is responsible for the following:

• manage the lifecycle of containers (from creation to destruction)

• pull / push container image

• storage management (manage the storage of image and container data)

• call runC run container (interact with runC and other container runtime)

• manage container network interfaces and networks

Note: the container is designed to be embedded in a larger system, not directly used by developers or end users.

We can understand why independent containerd is needed from the following points:

• continue to separate projects from the overall docker engine (the idea of open source projects)

• can be used by Kubernets CRI and other projects (generalization)

• lay the foundation for extensive industry cooperation (just like runC)

After docker is installed, containerd is installed by default. Containerd includes the following command components:

• containerd: high performance container runtime.

• ctr: command line client of containerd.

• runc: the command line tool that runs the container.

Docker, containerd, docker shim, runC relationships:

Docker: as far as docker itself is concerned, it includes docker client and dockerd. Dockerd is actually the top-level encapsulation of the api for container related operations, which is directly oriented to the operating users.

Containerd: what dockerd actually calls is the api interface of containerd (implemented in rpc). Containerd is an intermediate communication component between dockerd and runC.

Docker shim: a carrier that actually runs containers. Every time a container is started, a new docker shim process will be started. It creates a container by calling runC's api by specifying three parameters: container ID, boundary directory (containerd corresponds to the directory generated by a container), and runtime binary (runC by default).

runC: a command line tool that creates and runs containers according to OCI standards.

Container app
The default configuration file for containerd is / etc / containerd / config Toml, you can use the command:
containerd config default ## view the default configuration

Modify the default path of containerd Directory: / / demonstrate moving the containerd directory under / opt to / opt/docker/
:~$ sudo containerd config default > config_new.toml
//First print a default configuration file under the ~ directory
:~$ sudo mv /etc/containerd/config.toml /etc/containerd/config_bak20201126.toml
//Back up the original config
:~$ sudo mv configf_new.toml /etc/containerd/config.toml
//Move the file generated by default to the default configuration file path
:~$ sudo vi /etc/containerd/config.toml

          endpoint = [""]
      tls_cert_file = ""
      tls_key_file = ""
    path = "/opt/docker/containerd"       //Modify here
    interval = "10s"
    content_sharing_policy = "shared"
    no_prometheus = false
    shim = "containerd-shim"
    runtime = "runc"
    runtime_root = ""
    no_shim = false
    shim_debug = false
    platforms = ["linux/amd64"]
    default = ["walking"]
    root_path = ""
    pool_name = ""
    base_image_size = ""

:~$ sudo systemctl restart containerd.service / / restart the service and the modification succeeds

Tags: Docker

Posted by AStrangerWCandy on Thu, 05 May 2022 23:24:26 +0300