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.
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
... [plugins."io.containerd.grpc.v1.cri".registry] [plugins."io.containerd.grpc.v1.cri".registry.mirrors] [plugins."io.containerd.grpc.v1.cri".registry.mirrors."docker.io"] endpoint = ["https://registry-1.docker.io"] [plugins."io.containerd.grpc.v1.cri".x509_key_pair_streaming] tls_cert_file = "" tls_key_file = "" [plugins."io.containerd.internal.v1.opt"] path = "/opt/docker/containerd" //Modify here [plugins."io.containerd.internal.v1.restart"] interval = "10s" [plugins."io.containerd.metadata.v1.bolt"] content_sharing_policy = "shared" [plugins."io.containerd.monitor.v1.cgroups"] no_prometheus = false [plugins."io.containerd.runtime.v1.linux"] shim = "containerd-shim" runtime = "runc" runtime_root = "" no_shim = false shim_debug = false [plugins."io.containerd.runtime.v2.task"] platforms = ["linux/amd64"] [plugins."io.containerd.service.v1.diff-service"] default = ["walking"] [plugins."io.containerd.snapshotter.v1.devmapper"] root_path = "" pool_name = "" base_image_size = ""
:~$ sudo systemctl restart containerd.service / / restart the service and the modification succeeds