Docker の詳細
0 概要
docker info を使用して docker 実行の詳細を表示し、docker Inspection を使用してコンテナー実行の詳細を表示します。
containerd-shim
これはコンテナー ランタイム (rrunc は軽量のプロセス コンテナー ランタイム ツール) 間のブリッジとして機能し、コンテナーのcontainerd
作成、開始、停止、破棄などの操作を実行します。
1 つのドッカー情報
docker info
Client:
Context: default
Debug Mode: false
Plugins:
buildx: Docker Buildx (Docker Inc., v0.10.5)
compose: Docker Compose (Docker Inc., v2.18.1)
Server:
Containers: 118
Running: 96
Paused: 0
Stopped: 22
Images: 112
Server Version: 19.03.15
Storage Driver: overlay2
Backing Filesystem: xfs
Supports d_type: true
Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: systemd
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: d71fcd7d8303cbf684402823e425e9dd2e99285d
runc version: b9ee9c6314599f1b4a7f497e1f1f856fe433d3b7
init version: fec3683
Security Options:
seccomp
Profile: default
Kernel Version: 4.19.113-300.el7.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
CPUs: 8
Total Memory: 45.19GiB
Name: 172-30-30-101
ID: IXRP:MTDA:3XHX:CPCY:YQPP:7QEP:URNN:B2UY:H6EZ:DVHZ:EB2B:KEVC
Docker Root Dir: /var/lib/docker
Debug Mode: false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
0.0.0.0/0
127.0.0.0/8
Live Restore Enabled: true
WARNING: bridge-nf-call-ip6tables is disabled
上記の出力は、コマンドの実行docker info
後に返されるものです。このコマンドは、Docker ランタイム環境の詳細を表示するために使用されます。
解釈結果は以下の通りです。
クライアント(クライアント):
- コンテキスト: デフォルトのコンテキスト。
- デバッグ モード: デバッグ モードは無効になっています。
- プラグイン: Docker によってインストールされるプラグインのリスト。buildx および compose プラグインが含まれています。
サーバ:
- コンテナ: 現在 118 個のコンテナがあり、そのうち 96 個が実行中で、22 個が停止しています。
- 画像: 現在 112 枚の画像があります。
- サーバーのバージョン: Docker サーバーのバージョンは 19.03.15 です。
- ストレージ ドライバー: overlay2 をストレージ ドライバーとして使用します。
- バッキング ファイル システム (基礎となるファイル システム): ファイル システムは xfs を使用します。
- d_type をサポート: ファイル システムが d_type 機能をサポートしていることを意味します。
- ネイティブ オーバーレイ差分: ネイティブ オーバーレイ差分が有効かどうかを示します。
- ログドライバー: json-file をログドライバーとして使用します。
- Cgroup ドライバー (Cgroup ドライバー): Cgroup ドライバーとして systemd を使用します。
- プラグイン: Docker によってインストールされるプラグインのリスト。ボリューム、ネットワーク、ログなどのプラグインが含まれます。
- Swarm (クラスター): Swarm モードは非アクティブです。
- ランタイム (ランタイム): Docker はデフォルトのランタイムとして runc を使用します。
- デフォルトのランタイム: Runc がデフォルトでランタイムとして使用されます。
- Init Binary (初期バイナリ ファイル): Docker によって使用される初期化バイナリ ファイルは docker-init です。
- containerd version:containerdのバージョン情報。
- runc version: runcのバージョン情報。
- init version: イニシャライザのバージョン情報。
- セキュリティ オプション (セキュリティ オプション): セキュリティ オプションで seccomp が有効になっており、デフォルトの構成ファイルが使用されます。
- カーネル バージョン: オペレーティング システムのカーネル バージョンは 4.19.113-300.el7.x86_64 です。
- オペレーティング システム: Docker を実行しているオペレーティング システムは CentOS Linux 7 (Core) です。
- OSType: オペレーティング システムのタイプは Linux です。
- アーキテクチャ: ホスト アーキテクチャは x86_64 です。
- CPU (CPU の数): システムには 8 つの CPU があります。
- 合計メモリ: 合計システム メモリは 45.19GiB です。
- 名前: ホスト名は 172-30-30-101 です。
- ID: Docker によってこのホストに割り当てられた一意の ID。
- Docker Root Dir (Docker ルート ディレクトリ): Docker のルート ディレクトリは /var/lib/docker です。
- レジストリ (ミラー ウェアハウス): Docker ミラー ウェアハウスは https://index.docker.io/v1/ です。
- ラベル: Docker ラベルには値が設定されていません。
- 実験的: 実験的機能は有効になっていません。
- 安全でないレジストリ: 2 つのアドレス範囲 0.0.0.0/0 および 127.0.0.0/8 からミラーリングを取得できるようにします。
- ライブ リストアが有効: ライブ コンテナーのリストアが可能です。
警告:
- Bridge-nf-call-ip6tables は無効になっています。
2 ドッカー検査
このコマンドは、「k8s_etcd_etcd-172-30-30-101_kube-system_ccee5f78fdd19a28e13a2a9c4f8ba7c5_0」という名前の Docker コンテナーに関する詳細を返しました。
ここでは、いくつかの重要なフィールドについて説明します。
- Id : コンテナの一意の識別子。
- Created : コンテナーが作成されたときのタイムスタンプ。
- Path : コンテナのエントリ ポイントの実行可能ファイルへのパス。
- Args : コンテナのエントリ ポイントに渡される引数のリスト。
- State : 実行ステータス、プロセス ID、終了コードなどを含むコンテナのステータス情報。
- Image : コンテナーによって使用されるイメージの一意の識別子。
- HostConfig : マウント ポイント、ログ構成、ネットワーク モードなどを含むコンテナーのホスト構成。
- Mounts : コンテナにマウントされたファイル システムのパス。
- Config : ホスト名、環境変数、公開ポートなどを含むコンテナの構成情報。
- NetworkSettings : IP アドレス、ゲートウェイなどのコンテナーのネットワーク設定。
ここに示されている情報は完全ではない可能性があり、コマンドの出力は表示に適した形式になっていることに注意してください。
docker inspect k8s_etcd_etcd-172-30-30-101_kube-system_ccee5f78fdd19a28e13a2a9c4f8ba7c5_0
[
{
"Id": "76a3ff6175691b43aa67cedd3ff4f77ec47a1d3ed7a84990404b5ed88ee1e7e3",
"Created": "2023-07-10T02:24:28.843493987Z",
"Path": "etcd",
"Args": [
"--advertise-client-urls=https://172.30.30.101:2379",
"--cert-file=/etc/kubernetes/pki/etcd/server.crt",
"--client-cert-auth=true",
"--data-dir=/opt/qfusion/etcd",
"--initial-advertise-peer-urls=https://172.30.30.101:2380",
"--initial-cluster=172-30-30-101=https://172.30.30.101:2380",
"--key-file=/etc/kubernetes/pki/etcd/server.key",
"--listen-client-urls=https://127.0.0.1:2379,https://172.30.30.101:2379",
"--listen-metrics-urls=http://127.0.0.1:2381",
"--listen-peer-urls=https://172.30.30.101:2380",
"--name=172-30-30-101",
"--peer-cert-file=/etc/kubernetes/pki/etcd/peer.crt",
"--peer-client-cert-auth=true",
"--peer-key-file=/etc/kubernetes/pki/etcd/peer.key",
"--peer-trusted-ca-file=/etc/kubernetes/pki/etcd/ca.crt",
"--snapshot-count=10000",
"--trusted-ca-file=/etc/kubernetes/pki/etcd/ca.crt"
],
"State": {
"Status": "running",
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 11220,
"ExitCode": 0,
"Error": "",
"StartedAt": "2023-07-10T02:24:28.982141892Z",
"FinishedAt": "0001-01-01T00:00:00Z"
},
"Image": "sha256:303ce5db0e90dab1c5728ec70d21091201a23cdf8aeca70ab54943bbaaf0833f",
"ResolvConfPath": "/var/lib/docker/containers/7e86d443879d6e8d735c3e119aa096c36e70fea03cdd9a1ab7ef8ee21756b599/resolv.conf",
"HostnamePath": "/var/lib/docker/containers/7e86d443879d6e8d735c3e119aa096c36e70fea03cdd9a1ab7ef8ee21756b599/hostname",
"HostsPath": "/var/lib/kubelet/pods/ccee5f78fdd19a28e13a2a9c4f8ba7c5/etc-hosts",
"LogPath": "/var/lib/docker/containers/76a3ff6175691b43aa67cedd3ff4f77ec47a1d3ed7a84990404b5ed88ee1e7e3/76a3ff6175691b43aa67cedd3ff4f77ec47a1d3ed7a84990404b5ed88ee1e7e3-json.log",
"Name": "/k8s_etcd_etcd-172-30-30-101_kube-system_ccee5f78fdd19a28e13a2a9c4f8ba7c5_0",
"RestartCount": 0,
"Driver": "overlay2",
"Platform": "linux",
"MountLabel": "",
"ProcessLabel": "",
"AppArmorProfile": "",
"ExecIDs": null,
"HostConfig": {
"Binds": [
"/opt/qfusion/etcd:/opt/qfusion/etcd",
"/etc/kubernetes/pki/etcd:/etc/kubernetes/pki/etcd",
"/var/lib/kubelet/pods/ccee5f78fdd19a28e13a2a9c4f8ba7c5/etc-hosts:/etc/hosts",
"/var/lib/kubelet/pods/ccee5f78fdd19a28e13a2a9c4f8ba7c5/containers/etcd/5b7af2e8:/dev/termination-log"
],
"ContainerIDFile": "",
"LogConfig": {
"Type": "json-file",
"Config": {
"max-size": "100m"
}
},
"NetworkMode": "container:7e86d443879d6e8d735c3e119aa096c36e70fea03cdd9a1ab7ef8ee21756b599",
"PortBindings": null,
"RestartPolicy": {
"Name": "no",
"MaximumRetryCount": 0
},
"AutoRemove": false,
"VolumeDriver": "",
"VolumesFrom": null,
"CapAdd": null,
"CapDrop": null,
"Capabilities": null,
"Dns": null,
"DnsOptions": null,
"DnsSearch": null,
"ExtraHosts": null,
"GroupAdd": null,
"IpcMode": "container:7e86d443879d6e8d735c3e119aa096c36e70fea03cdd9a1ab7ef8ee21756b599",
"Cgroup": "",
"Links": null,
"OomScoreAdj": -998,
"PidMode": "",
"Privileged": false,
"PublishAllPorts": false,
"ReadonlyRootfs": false,
"SecurityOpt": [
"seccomp=unconfined"
],
"UTSMode": "host",
"UsernsMode": "",
"ShmSize": 67108864,
"Runtime": "runc",
"ConsoleSize": [
0,
0
],
"Isolation": "",
"CpuShares": 2,
"Memory": 0,
"NanoCpus": 0,
"CgroupParent": "kubepods-besteffort-podccee5f78fdd19a28e13a2a9c4f8ba7c5.slice",
"BlkioWeight": 0,
"BlkioWeightDevice": null,
"BlkioDeviceReadBps": null,
"BlkioDeviceWriteBps": null,
"BlkioDeviceReadIOps": null,
"BlkioDeviceWriteIOps": null,
"CpuPeriod": 100000,
"CpuQuota": 0,
"CpuRealtimePeriod": 0,
"CpuRealtimeRuntime": 0,
"CpusetCpus": "",
"CpusetMems": "",
"Devices": [],
"DeviceCgroupRules": null,
"DeviceRequests": null,
"KernelMemory": 0,
"KernelMemoryTCP": 0,
"MemoryReservation": 0,
"MemorySwap": 0,
"MemorySwappiness": null,
"OomKillDisable": false,
"PidsLimit": null,
"Ulimits": null,
"CpuCount": 0,
"CpuPercent": 0,
"IOMaximumIOps": 0,
"IOMaximumBandwidth": 0,
"MaskedPaths": [
"/proc/acpi",
"/proc/kcore",
"/proc/keys",
"/proc/latency_stats",
"/proc/timer_list",
"/proc/timer_stats",
"/proc/sched_debug",
"/proc/scsi",
"/sys/firmware"
],
"ReadonlyPaths": [
"/proc/asound",
"/proc/bus",
"/proc/fs",
"/proc/irq",
"/proc/sys",
"/proc/sysrq-trigger"
]
},
"GraphDriver": {
"Data": {
"LowerDir": "/var/lib/docker/overlay2/b47eed97a959e733f2f5583d689a884d4d8c73f510872b0b1ba429140b8a8d49-init/diff:/var/lib/docker/overlay2/2fb3706abf15c0aef48416ff665012d38d6c7692a16245ac570d14d1df3a8c9e/diff:/var/lib/docker/overlay2/18f09190247c06ef5cb98494b5919f94cedd3a38a1a822dcbe319447a456825f/diff:/var/lib/docker/overlay2/e11e2abdfe4bd69b64f42b9f127be980e3cd1491ef70ea8e3bb9420b4a8ffeef/diff",
"MergedDir": "/var/lib/docker/overlay2/b47eed97a959e733f2f5583d689a884d4d8c73f510872b0b1ba429140b8a8d49/merged",
"UpperDir": "/var/lib/docker/overlay2/b47eed97a959e733f2f5583d689a884d4d8c73f510872b0b1ba429140b8a8d49/diff",
"WorkDir": "/var/lib/docker/overlay2/b47eed97a959e733f2f5583d689a884d4d8c73f510872b0b1ba429140b8a8d49/work"
},
"Name": "overlay2"
},
"Mounts": [
{
"Type": "bind",
"Source": "/var/lib/kubelet/pods/ccee5f78fdd19a28e13a2a9c4f8ba7c5/etc-hosts",
"Destination": "/etc/hosts",
"Mode": "",
"RW": true,
"Propagation": "rprivate"
},
{
"Type": "bind",
"Source": "/var/lib/kubelet/pods/ccee5f78fdd19a28e13a2a9c4f8ba7c5/containers/etcd/5b7af2e8",
"Destination": "/dev/termination-log",
"Mode": "",
"RW": true,
"Propagation": "rprivate"
},
{
"Type": "bind",
"Source": "/opt/qfusion/etcd",
"Destination": "/opt/qfusion/etcd",
"Mode": "",
"RW": true,
"Propagation": "rprivate"
},
{
"Type": "bind",
"Source": "/etc/kubernetes/pki/etcd",
"Destination": "/etc/kubernetes/pki/etcd",
"Mode": "",
"RW": true,
"Propagation": "rprivate"
}
],
"Config": {
"Hostname": "172-30-30-101",
"Domainname": "",
"User": "0",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"ExposedPorts": {
"2379/tcp": {
},
"2380/tcp": {
},
"4001/tcp": {
},
"7001/tcp": {
}
},
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
],
"Cmd": null,
"Healthcheck": {
"Test": [
"NONE"
]
},
"Image": "sha256:303ce5db0e90dab1c5728ec70d21091201a23cdf8aeca70ab54943bbaaf0833f",
"Volumes": null,
"WorkingDir": "",
"Entrypoint": [
"etcd",
"--advertise-client-urls=https://172.30.30.101:2379",
"--cert-file=/etc/kubernetes/pki/etcd/server.crt",
"--client-cert-auth=true",
"--data-dir=/opt/qfusion/etcd",
"--initial-advertise-peer-urls=https://172.30.30.101:2380",
"--initial-cluster=172-30-30-101=https://172.30.30.101:2380",
"--key-file=/etc/kubernetes/pki/etcd/server.key",
"--listen-client-urls=https://127.0.0.1:2379,https://172.30.30.101:2379",
"--listen-metrics-urls=http://127.0.0.1:2381",
"--listen-peer-urls=https://172.30.30.101:2380",
"--name=172-30-30-101",
"--peer-cert-file=/etc/kubernetes/pki/etcd/peer.crt",
"--peer-client-cert-auth=true",
"--peer-key-file=/etc/kubernetes/pki/etcd/peer.key",
"--peer-trusted-ca-file=/etc/kubernetes/pki/etcd/ca.crt",
"--snapshot-count=10000",
"--trusted-ca-file=/etc/kubernetes/pki/etcd/ca.crt"
],
"OnBuild": null,
"Labels": {
"annotation.io.kubernetes.container.hash": "9fdc85e1",
"annotation.io.kubernetes.container.restartCount": "0",
"annotation.io.kubernetes.container.terminationMessagePath": "/dev/termination-log",
"annotation.io.kubernetes.container.terminationMessagePolicy": "File",
"annotation.io.kubernetes.pod.terminationGracePeriod": "30",
"io.kubernetes.container.logpath": "/var/log/pods/kube-system_etcd-172-30-30-101_ccee5f78fdd19a28e13a2a9c4f8ba7c5/etcd/0.log",
"io.kubernetes.container.name": "etcd",
"io.kubernetes.docker.type": "container",
"io.kubernetes.pod.name": "etcd-172-30-30-101",
"io.kubernetes.pod.namespace": "kube-system",
"io.kubernetes.pod.uid": "ccee5f78fdd19a28e13a2a9c4f8ba7c5",
"io.kubernetes.sandbox.id": "7e86d443879d6e8d735c3e119aa096c36e70fea03cdd9a1ab7ef8ee21756b599"
}
},
"NetworkSettings": {
"Bridge": "",
"SandboxID": "",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {
},
"SandboxKey": "",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "",
"Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "",
"IPPrefixLen": 0,
"IPv6Gateway": "",
"MacAddress": "",
"Networks": {
}
}
}
]
3 ll /var/lib/docker ディレクトリ
ll /var/lib/docker
总用量 104
drwx------ 2 root root 24 7月 10 10:06 builder
drwx--x--x 4 root root 92 7月 10 10:06 buildkit
drwx-----x 120 root root 16384 7月 14 15:27 containers
drwx------ 3 root root 22 7月 10 10:06 image
drwxr-x--- 3 root root 19 7月 10 10:06 network
drwx-----x 794 root root 69632 7月 14 22:07 overlay2
drwx------ 4 root root 32 7月 10 10:06 plugins
drwx------ 2 root root 6 7月 10 10:17 runtimes
drwx------ 2 root root 6 7月 10 10:06 swarm
drwx------ 2 root root 6 7月 14 22:07 tmp
drwx------ 2 root root 6 7月 10 10:06 trust
drwx-----x 2 root root 25 7月 10 10:06 volumes
/var/lib/docker ディレクトリ内の各サブディレクトリの機能は次のとおりです。
- builder: ビルダー関連ファイルが含まれます。
- buildkit: BuildKit に関連するファイルが含まれています。
- コンテナ: すべてのコンテナの情報とステータスが含まれます。
- image: Docker イメージの関連情報とファイルが含まれています。
- network: Docker ネットワークに関する情報が含まれます。
- overlay2: overlay2 を使用して、overlay2 によって駆動されるコンテナ レイヤーとイメージ レイヤーを保存します。
- plugins: Docker プラグインの関連ファイルが含まれます。
- runtimes: コンテナー ランタイムの関連ファイルが含まれます。
- swarm: Swarm モードに関連するファイルが含まれます。
- tmp: 一時フォルダー。一時ファイルの保存に使用されます。
- trust: 信頼関連のファイルが含まれます。
- ボリューム: Docker ボリュームに関する情報が含まれます。
これらのディレクトリは Docker ランタイムにとって非常に重要であり、Docker のさまざまな構成、コンテナ、イメージ、その他のデータが保存されます。
4 ドッカード
/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
dockerd
これは、Docker コンテナーの管理と実行を担当する Docker のデーモン プロセスです。これは Docker エンジンのコア コンポーネントの 1 つであり、ユーザーと対話し、コンテナーの作成、開始、停止などの操作を処理するために使用されます。
の主な機能をいくつか紹介しますdockerd
。
-
コンテナーのライフサイクル管理:
dockerd
コンテナーの作成、開始、停止、破棄を担当します。コンテナの状態を監視し、適切なタイミングで調整を行うことができます。 -
イメージ管理:
dockerd
Dockerイメージの管理機能を提供します。リモート リポジトリからイメージをダウンロードし、新しいイメージを構築してリポジトリにプッシュできます。 -
リソース分離:
dockerd
Linux カーネルによって提供される仮想化テクノロジ (名前空間や制御グループなど) を使用して、コンテナーのリソース分離を実装します。これにより、複数のコンテナが互いに干渉することなく、同じホスト上で並行して実行できるようになります。 -
ネットワーク管理:
dockerd
ネットワーク接続とコンテナの構成を管理します。コンテナに IP アドレスを割り当て、他のコンテナや外部ネットワークと通信できます。 -
ロギング:
dockerd
コンテナーのログ情報を収集し、ユーザーが簡単に表示および分析できるようにローカルまたはリモートのストレージに保存できます。
上記機能に加えてdockerd
プラグイン機構もサポートしており、プラグインをインストールして使用することで機能を拡張できます。また、ユーザーが Docker エンジンと対話し、コンテナーやイメージを管理できるようにするコマンドライン インターフェイス (CLI) と API の豊富なセットも提供します。
注: ほとんどの場合、ユーザーはdockerd
Docker エンジンと直接対話するのではなく、Docker CLI または他の Docker 関連ツールを介して対話します。
5 docker-containerd > crictl ctr
コンテナ
containerd は、Docker エンジンの一部であるオープンソースのコンテナー ランタイム ツールです。コンテナのライフサイクル、イメージ管理、コンテナ ネットワーキング、ストレージを管理するための標準インターフェイスと機能を提供します。
Containerd の設計目標は、さまざまなシナリオのニーズを満たす、信頼性の高い軽量のコンテナー ランタイム環境を提供することです。モジュラー アーキテクチャを採用し、さまざまな機能をさまざまなコンポーネントに分割し、gRPC インターフェイスを通じて通信します。これにより、ユーザーは不要なコンポーネントをロードすることなく、必要に応じて必要な機能を選択して使用することができます。
containerd は、ユーザーがコンテナーを簡単に作成、実行、一時停止、再開、削除できるようにする強力なコマンドライン ツールと API のセットを提供します。また、イメージのプル、エクスポート、削除もサポートしているため、ユーザーはコンテナ間でイメージを共有して再利用できます。さらに、containerd は、コンテナ間のネットワークを構成および管理するためのネットワーク プラグイン システムを提供します。
ユーザーは、containerd のプラグイン メカニズムを通じて、新しいコンテナー ランタイム、ストレージ バックエンド、ネットワーク ドライバーの追加など、その機能を拡張できます。これにより、containerd は、さまざまなユースケースやデプロイメント環境に対応した柔軟でカスタマイズ可能なコンテナ管理ツールになります。
つまり、containerd は強力で安定性と信頼性の高いコンテナ ランタイム ツールであり、豊富な機能と柔軟なアーキテクチャを提供し、ユーザーがコンテナ化されたアプリケーションをより効果的に管理および実行できるようにします。
/var/lib/containerd/
/var/lib/containerd/
ディレクトリ下の各サブディレクトリの中国語の紹介と機能は次のとおりです。
-
io.containerd.content.v1.content
: このディレクトリには、コンテナー ランタイムによって使用されるコンテンツ (イメージやファイル システム レイヤーなど) が保存されます。 -
io.containerd.metadata.v1.bolt
: このディレクトリには、BoltDB データベースを使用して保存されるコンテナ メタデータが含まれます。 -
io.containerd.runtime.v1.linux
: このディレクトリはコンテナ ランタイムの場所であり、主に Linux コンテナのランタイム ステータスと情報が保存されます。 -
io.containerd.runtime.v2.task
: このディレクトリは、v2 コンテナ タスクに関連する情報を保存するために使用されます。 -
io.containerd.snapshotter.v1.native
: このディレクトリは、ストレージにネイティブ スナッパーを使用するコンテナ スナップショット マネージャーの場所です。 -
io.containerd.snapshotter.v1.overlayfs
: このディレクトリは、ストレージに OverlayFS スナップショットを使用するコンテナ スナップショット マネージャーの場所です。 -
tmpmounts
: このディレクトリは、一時ファイルシステムをマウントするために使用されます。
ll /run/containerd/
ll /run/containerd/
このコマンドは、/run/containerd/
ディレクトリ配下のファイルやフォルダーの詳細情報を表示するために使用します。
提供した出力に基づいて、/run/containerd/
ディレクトリの内容は次のとおりです。
containerd.sock
: これは、Containerd デーモンとの通信に使用されるソケット ファイルです。containerd.sock.ttrpc
: これもソケット ファイルですが、通信には ttrpc プロトコルを使用します。io.containerd.runtime.v1.linux
: これは、Containerd ランタイムに関連するファイルが含まれる可能性があるフォルダーです。io.containerd.runtime.v2.task
: これは、Containerd タスク ランタイムに関連するファイルが含まれる可能性があるフォルダーです。s
:サイズが1960バイトのフォルダーです。このフォルダーには、他の Containerd 関連のファイルまたはデータが含まれている場合があります。
一般に、/run/containerd/
ディレクトリはコンテナ ランタイム管理プログラム Containerd によって使用されるディレクトリであり、コンテナ ランタイムに関連するファイルとフォルダが含まれます。
拡張
ttrpc (Tiny Transport RPC) プロトコルは、軽量のリモート プロシージャ コール (RPC) プロトコルです。効率的で簡潔な通信メカニズムを提供し、異なるプロセスまたはデバイス間で信頼性の高い通信とメソッド呼び出しを可能にすることを目的としています。ttrpc プロトコルと他のプロトコルとの違いは次のとおりです。
-
軽量: ttrpc プロトコルは設計がシンプルでオーバーヘッドが小さいため、組み込みシステムやリソースに制約のある環境に適しています。
-
パフォーマンスの最適化: ttrpc プロトコルは、パケットのサイズと数を削減することでパフォーマンスを向上させます。コンパクトなバイナリ形式を使用し、不要な場合の冗長な情報の送信を回避します。
-
複数のトランスポート層のサポート: ttrpc プロトコルは、TCP、UDP、UNIX ドメイン ソケットなどのさまざまなトランスポート層で実行できます。これにより、より柔軟でさまざまなネットワーク環境に適応できるようになります。
-
信頼性: ttrpc プロトコルは、メッセージの整合性と順序を保証する信頼性の高いメッセージ配信メカニズムを提供します。確認応答と再送信のメカニズムを使用して、失われたメッセージや破損したメッセージを処理します。
-
多言語サポート: ttrpc プロトコルには多言語バインディングがあるため、さまざまなプログラミング言語で対話して使用できます。
一般に、ttrpc プロトコルは、オーバーヘッドが少なく柔軟性のある簡潔で効率的な軽量 RPC プロトコルであり、リソースに制約のある環境で信頼性の高い通信メカニズムを提供します。
RPC(Remote Procedure Call)プロトコルは、異なるコンピュータ間の通信に使用されるプロトコルです。これにより、コンピューター プログラムは、あたかもネイティブ プログラムであるかのように、別のコンピューター上のサブルーチンまたは関数を呼び出すことができます。RPC プロトコルは、基礎となるネットワーク通信の詳細を隠し、リモート呼び出しをローカル呼び出しのように見せます。
RPC プロトコルの基本原理は、クライアントとサーバー間の通信を通じてリモート プロシージャ コールを実現することです。クライアントはリクエスト メッセージをサーバーに送信し、サーバーは対応する操作を実行して、結果をクライアントに返します。RPC プロトコルは、正しい呼び出しと応答を保証するために、メッセージの形式と対話を定義します。
RPC プロトコルの主な機能は次のとおりです。
-
透過性: RPC プロトコルはネットワーク通信の複雑さを隠し、開発者にとってリモート呼び出しを透過的にします。開発者は、基盤となるネットワークの詳細を気にすることなく、ローカル関数を呼び出すのと同じようにリモート関数を呼び出すことができます。
-
独立性: RPC プロトコルは、特定のプログラミング言語やプラットフォームから独立しています。これは、クライアントとサーバーが同じ RPC プロトコル仕様に従っている限り、異なるプログラミング言語を使用して実装できることを意味します。
-
スケーラビリティ: RPC プロトコルは、分散環境でのアプリケーションの拡張をサポートします。異なる機能モジュールを異なるコンピュータに展開し、RPC プロトコルを通じて通信して分散コンピューティングを実現できます。
-
セキュリティ: RPC プロトコルは安全な通信方法を提供します。暗号化や認証などのメカニズムを通じて、通信の機密性と完全性を確保できます。
一般的な RPC プロトコルには、XML-RPC、JSON-RPC、gRPC などがあります。これらのプロトコルは、データのエンコード形式、伝送モード、パフォーマンスの点で異なり、開発者は特定のニーズに応じて適切なプロトコルを選択できます。
クリトル
crictl -h
NAME:
crictl - client for CRI
USAGE:
crictl [global options] command [command options] [arguments...]
VERSION:
v1.13.0
COMMANDS:
attach Attach to a running container
create Create a new container
exec Run a command in a running container
version Display runtime version information
images List images
inspect Display the status of one or more containers
inspecti Return the status of one or more images
inspectp Display the status of one or more pods
logs Fetch the logs of a container
port-forward Forward local port to a pod
ps List containers
pull Pull an image from a registry
runp Run a new pod
rm Remove one or more containers
rmi Remove one or more images
rmp Remove one or more pods
pods List pods
start Start one or more created containers
info Display information of the container runtime
stop Stop one or more running containers
stopp Stop one or more running pods
update Update one or more running containers
config Get and set crictl options
stats List container(s) resource usage statistics
completion Output bash shell completion code
help, h Shows a list of commands or help for one command
GLOBAL OPTIONS:
--config value, -c value Location of the client config file (default: "/etc/crictl.yaml") [$CRI_CONFIG_FILE]
--debug, -D Enable debug mode
--image-endpoint value, -i value Endpoint of CRI image manager service [$IMAGE_SERVICE_ENDPOINT]
--runtime-endpoint value, -r value Endpoint of CRI container runtime service (default: "unix:///var/run/dockershim.sock") [$CONTAINER_RUNTIME_ENDPOINT]
--timeout value, -t value Timeout of connecting to the server (default: 10s)
--help, -h show help
--version, -v print the version
crictl
と は、docker
コンテナー ランタイム環境を管理するための 2 つの異なるコマンドライン ツールです。
1. 機能の違い:
crictl
これは、コンテナー ランタイムと通信するコマンド ライン ツールで、コンテナーの作成、開始、停止、削除など、基盤となるコンテナー ランタイムの機能を管理および操作するために使用されます。これは主に、Docker の標準コンテナ ランタイムcontainerd
や Kubernetes コンテナ ランタイムなど、CRI (Container Runtime Interface) と互換性のあるコンテナ ランタイムと対話するために使用されますcri-o
。docker
これは、イメージの構築、コンテナの作成、コンテナ ネットワーク、ストレージ ボリュームの管理など、高レベルの機能と抽象化を提供する完全なコンテナ プラットフォームです。これは、コンテナ アプリケーションを簡単に構築、デプロイ、管理できる開発者と運用者向けのツールです。
2. さまざまな使用シナリオ:
crictl
これは、コンテナー ランタイムの問題のデバッグ、基になるコンテナーのステータスの表示、コンテナーの手動管理など、コンテナー ランタイム レベルでの操作により適しています。これは、コンテナー ランタイムと直接対話する必要があるユーザーまたは開発者にとって便利です。docker
アプリケーションの構築、公開、管理、マルチコンテナ アプリケーション オーケストレーション、コンテナ クラスタ管理など、より高いレベルでコンテナ テクノロジを使用することがより適しています。これは、アプリケーションの開発およびデプロイメントにコンテナを使用する必要があるユーザーまたはオペレーターにとって、より便利です。
したがって、ニーズと用途に応じて、 と の間には機能と使用シナリオに一定の違いがありますcrictl
。docker
6 docker-containerd-shim
containerd-shim
は、Docker チームによって開発および保守されているオープンソースのコンテナー ランタイム コンポーネントです。containerd
これは、デーモンと対話し、コンテナーの作成、開始、停止、破棄を調整する責任を負います。
具体的には、containerd-shim
コンテナのライフサイクルにおいて重要な役割を果たしており、主に以下の機能を持っています。
-
コンテナの作成: ユーザーがコンテナの作成をリクエストすると、デーモンプロセス
containerd-shim
からリクエストを受け取り、指定された構成パラメータに従って対応するコンテナを作成します。containerd
-
コンテナーの起動と管理: コンテナーが作成されると、
containerd-shim
コンテナーはコンテナーを起動し、その実行ステータスを監視します。コンテナーの名前空間と対話して、コンテナー内にファイル システム、ネットワーク、およびプロセスの分離を実装します。同時に、containerd-shim
コンテナ内の標準入出力 (stdin/stdout) と信号送信の処理も担当します。 -
コンテナの停止と破棄: ユーザーがコンテナの停止または破棄を要求すると、コンテナ
containerd-shim
は対応するコマンドを受け取り、対応する操作を実行します。コンテナ内のプロセスに信号を送信し、コンテナ関連のリソースを停止してクリーンアップするように指示します。
つまり、containerd-shim
コンテナー ランタイムと の間のブリッジとして機能しcontainerd
、コンテナーの作成、開始、停止、破棄などの操作を実行します。これはコンテナを基盤となるインフラストラクチャに接続する役割を果たし、コンテナが安全で独立した環境で実行できるようにします。
7 docker-runc > runc
runc は、コンテナーの作成と実行に使用できる軽量のプロセス コンテナー ランタイム ツールです。これは OCI (Open Container Initiative) 標準の一部であり、コンテナ内のプロセスの管理と実行を担当します。
runc の主な機能は次のとおりです。
-
コンテナーの作成: runc は、指定された構成ファイルに基づいてコンテナーを作成できます。これらの構成ファイルは、名前空間、ファイルシステムのマウント、リソース制限など、コンテナーのさまざまなプロパティを定義します。
-
コンテナーを実行します。 runc は、コンテナー内で定義されたプロセスを開始し、コンテナー内に必要な名前空間と分離環境を作成できます。プロセス環境変数、ファイル システム、ネットワーク構成など、コンテナーの実行時構成を設定する役割を果たします。
-
コンテナのライフサイクル管理: runc はコンテナのライフサイクルを管理する機能を提供します。コンテナーを開始し、コンテナーのステータスを監視し、必要に応じてコンテナーを停止または破棄できます。
-
コンテナの分離を実現する: runc は、Linux カーネルの名前空間と cgroup メカニズムを使用して、コンテナの分離を実現します。各コンテナーには独立した名前空間があるため、コンテナー内のプロセスは実行時に他のコンテナーやホスト システムの存在を認識できません。
全体として、runc はコンテナーを管理および実行するためのシンプルで信頼性の高い方法を提供し、コンテナー化されたアプリケーションを構築および使用するためのインフラストラクチャを提供します。Docker、Kubernetes などのさまざまなコンテナ管理ツールやプラットフォームで広く使用されています。
CRIのruncとcontainerd
8つのdockerコマンド
docker -h
Flag shorthand -h has been deprecated, please use --help
Usage: docker [OPTIONS] COMMAND
A self-sufficient runtime for containers
Options:
--config string Location of client config files (default "/root/.docker")
-c, --context string Name of the context to use to connect to the daemon (overrides DOCKER_HOST env var and
default context set with "docker context use")
-D, --debug Enable debug mode
-H, --host list Daemon socket(s) to connect to
-l, --log-level string Set the logging level ("debug"|"info"|"warn"|"error"|"fatal") (default "info")
--tls Use TLS; implied by --tlsverify
--tlscacert string Trust certs signed only by this CA (default "/root/.docker/ca.pem")
--tlscert string Path to TLS certificate file (default "/root/.docker/cert.pem")
--tlskey string Path to TLS key file (default "/root/.docker/key.pem")
--tlsverify Use TLS and verify the remote
-v, --version Print version information and quit
Management Commands:
builder Manage builds
buildx* Docker Buildx (Docker Inc., v0.10.5)
compose* Docker Compose (Docker Inc., v2.18.1)
config Manage Docker configs
container Manage containers
context Manage contexts
image Manage images
manifest Manage Docker image manifests and manifest lists
network Manage networks
node Manage Swarm nodes
plugin Manage plugins
secret Manage Docker secrets
service Manage services
stack Manage Docker stacks
swarm Manage Swarm
system Manage Docker
trust Manage trust on Docker images
volume Manage volumes
Commands:
attach Attach local standard input, output, and error streams to a running container
build Build an image from a Dockerfile
commit Create a new image from a container's changes
cp Copy files/folders between a container and the local filesystem
create Create a new container
diff Inspect changes to files or directories on a container's filesystem
events Get real time events from the server
exec Run a command in a running container
export Export a container's filesystem as a tar archive
history Show the history of an image
images List images
import Import the contents from a tarball to create a filesystem image
info Display system-wide information
inspect Return low-level information on Docker objects
kill Kill one or more running containers
load Load an image from a tar archive or STDIN
login Log in to a Docker registry
logout Log out from a Docker registry
logs Fetch the logs of a container
pause Pause all processes within one or more containers
port List port mappings or a specific mapping for the container
ps List containers
pull Pull an image or a repository from a registry
push Push an image or a repository to a registry
rename Rename a container
restart Restart one or more containers
rm Remove one or more containers
rmi Remove one or more images
run Run a command in a new container
save Save one or more images to a tar archive (streamed to STDOUT by default)
search Search the Docker Hub for images
start Start one or more stopped containers
stats Display a live stream of container(s) resource usage statistics
stop Stop one or more running containers
tag Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE
top Display the running processes of a container
unpause Unpause all processes within one or more containers
update Update configuration of one or more containers
version Show the Docker version information
wait Block until one or more containers stop, then print their exit codes
Run 'docker COMMAND --help' for more information on a command.
To get more help with docker, check out our guides at https://docs.docker.com/go/guides/