[containerd] 全局参数——root & state参数的含义

  执行,containerd help,你会发现,containerdglobol options中有两个参数,一个为root,一个为state。这两个参数乍一看上去搞得很懵逼,着实有点不理解到底是用来配置什么的。

root@containerd:/run/containerd# containerd help
NAME:
   containerd -
                    __        _                     __
  _________  ____  / /_____ _(_)___  ___  _________/ /
 / ___/ __ \/ __ \/ __/ __ `/ / __ \/ _ \/ ___/ __  /
/ /__/ /_/ / / / / /_/ /_/ / / / / /  __/ /  / /_/ /
\___/\____/_/ /_/\__/\__,_/_/_/ /_/\___/_/   \__,_/

high performance container runtime


USAGE:
   containerd [global options] command [command options] [arguments...]

VERSION:
   v1.7.2

DESCRIPTION:

containerd is a high performance container runtime whose daemon can be started
by using this command. If none of the *config*, *publish*, *oci-hook*, or *help* commands
are specified, the default action of the **containerd** command is to start the
containerd daemon in the foreground.


A default configuration is used if no TOML configuration is specified or located
at the default file location. The *containerd config* command can be used to
generate the default configuration for containerd. The output of that command
can be used and modified as necessary as a custom configuration.

COMMANDS:
   config    Information on the containerd config
   publish   Binary to publish events to containerd
   oci-hook  Provides a base for OCI runtime hooks to allow arguments to be injected.
   help, h   Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --config value, -c value     Path to the configuration file (default: "/etc/containerd/config.toml")
   --log-level value, -l value  Set the logging level [trace, debug, info, warn, error, fatal, panic]
   --address value, -a value    Address for containerd's GRPC server
   --root value                 containerd root directory
   --state value                containerd state directory
   --help, -h                   show help
   --version, -v                print the version
root@containerd:/run/containerd#

  通过debug containerd源码,我发现root默认值为/var/lib/containerd;而state默认值为/run/containerd。看到这里你是不是一下就明白这两个参数的作用了?实际上root参数是为cotnainerd指定元数据的存放位置,譬如镜像,运行时的一些数据。state参数则是为了指定containerd监听的socket文件的位置。

root@containerd:/run/containerd# tree -L 3 /var/lib/containerd/
/var/lib/containerd/
├── io.containerd.content.v1.content
│   ├── blobs
│   │   └── sha256
│   └── ingest
├── io.containerd.metadata.v1.bolt
│   └── meta.db
├── io.containerd.runtime.v1.linux
├── io.containerd.runtime.v2.task
├── io.containerd.snapshotter.v1.btrfs
├── io.containerd.snapshotter.v1.native
│   └── snapshots
├── io.containerd.snapshotter.v1.overlayfs
│   ├── metadata.db
│   └── snapshots
│       ├── 48
│       ├── 61
│       ├── 62
│       ├── 63
│       ├── 64
│       ├── 65
│       ├── 66
│       ├── 67
│       ├── 68
│       ├── 69
│       ├── 70
│       ├── 71
│       ├── 72
│       └── 75
└── tmpmounts

27 directories, 2 files
root@containerd:/run/containerd#
root@containerd:/run/containerd#
root@containerd:/run/containerd# tree -L 3 /run/containerd/
/run/containerd/
├── containerd.sock.ttrpc
├── io.containerd.runtime.v1.linux
└── io.containerd.runtime.v2.task

2 directories, 1 file
root@containerd:/run/containerd#

你可能感兴趣的:(ContainerD,containerd,全局参数,root,state)