ctr containers ls 什么都没有

what 发表于: 2022-08-16   最后更新时间: 2022-08-16 19:09:46   1,384 游览

当我使用 "ctr containers ls "命令来获取正在运行的容器时,我什么也得不到。

# ctr containers ls
CONTAINER    IMAGE    RUNTIME

但是,当我使用命令systemctl status containers来获取有关 containerd 的信息时。我发现有很多容器。比如:

# systemctl status containerd
● containerd.service - containerd container runtime
   Loaded: loaded (/etc/systemd/system/containerd.service; disabled; vendor preset: disabled)
   Active: active (running) since Mon 2017-11-20 19:02:48 CST; 6 days ago
     Docs: https://containerd.io
 Main PID: 31436 (containerd)
   Memory: 481.0M
   CGroup: /system.slice/containerd.service
           ├─  353 containerd-shim --namespace k8s.io --workdir /var/lib/containerd/io.containerd.runtime.v1.linux/k...
           ├─  524 containerd-shim --namespace k8s.io --workdir /var/lib/containerd/io.containerd.runtime.v1.linux/k...
           ├─  591 containerd-shim --namespace k8s.io --workdir /var/lib/containerd/io.containerd.runtime.v1.linux/k...
           ├─  625 containerd-shim --namespace k8s.io --workdir /var/lib/containerd/io.containerd.runtime.v1.linux/k...
           ├─  831 containerd-shim --namespace k8s.io --workdir /var/lib/containerd/io.containerd.runtime.v1.linux/k...
           ├─ 5066 containerd-shim --namespace k8s.io --workdir /var/lib/containerd/io.containerd.runtime.v1.linux/k...
           ├─ 5134 containerd-shim --namespace k8s.io --workdir /var/lib/containerd/io.containerd.runtime.v1.linux/k...
           ├─ 5451 containerd-shim --namespace k8s.io --workdir /var/lib/containerd/io.containerd.runtime.v1.linux/k...
           ├─ 9056 containerd-shim --namespace k8s.io --workdir /var/lib/containerd/io.containerd.runtime.v1.linux/k...
           ├─ 9595 containerd-shim --namespace k8s.io --workdir /var/lib/containerd/io.containerd.runtime.v1.linux/k...
           ├─ 9809 containerd-shim --namespace k8s.io --workdir /var/lib/containerd/io.containerd.runtime.v1.linux/k...
           ├─ 9991 containerd-shim --namespace k8s.io --workdir /var/lib/containerd/io.containerd.runtime.v1.linux/k...
           ├─10194 containerd-shim --namespace k8s.io --workdir /var/lib/containerd/io.containerd.runtime.v1.linux/k...
           ├─11532 n/a
           ├─18009 containerd-shim --namespace k8s.io --workdir /var/lib/containerd/io.containerd.runtime.v1.linux/k...
           ├─18620 containerd-shim --namespace k8s.io --workdir /var/lib/containerd/io.containerd.runtime.v1.linux/k...
           ├─20173 containerd-shim --namespace k8s.io --workdir /var/lib/containerd/io.containerd.runtime.v1.linux/k...
           ├─21220 containerd-shim --namespace k8s.io --workdir /var/lib/containerd/io.containerd.runtime.v1.linux/k...
           ├─27893 containerd-shim --namespace k8s.io --workdir /var/lib/containerd/io.containerd.runtime.v1.linux/k...
           ├─29233 containerd-shim --namespace k8s.io --workdir /var/lib/containerd/io.containerd.runtime.v1.linux/k...
           ├─31436 /usr/local/bin/containerd --log-level=debug
           ├─31575 containerd-shim --namespace k8s.io --workdir /var/lib/containerd/io.containerd.runtime.v1.linux/k...
           ├─31577 containerd-shim --namespace k8s.io --workdir /var/lib/containerd/io.containerd.runtime.v1.linux/k...
           ├─31578 containerd-shim --namespace k8s.io --workdir /var/lib/containerd/io.containerd.runtime.v1.linux/k...
           ├─31619 containerd-shim --namespace k8s.io --workdir /var/lib/containerd/io.containerd.runtime.v1.linux/k...
           ├─31844 containerd-shim --namespace k8s.io --workdir /var/lib/containerd/io.containerd.runtime.v1.linux/k...
           ├─31892 containerd-shim --namespace k8s.io --workdir /var/lib/containerd/io.containerd.runtime.v1.linux/k...
           ├─31901 containerd-shim --namespace k8s.io --workdir /var/lib/containerd/io.containerd.runtime.v1.linux/k...
           ├─31918 containerd-shim --namespace k8s.io --workdir /var/lib/containerd/io.containerd.runtime.v1.linux/k...
           └─32765 containerd-shim --namespace k8s.io --workdir /var/lib/containerd/io.containerd.runtime.v1.linux/k...

ctr containers ls命令有什么问题吗?

发表于 2022-08-16

containerd默认命名空间的,如果是基于k8s的,默认命名空间是k8s.io,加上就可以了:

ctr --namespace k8s.io containers ls
what -> 半兽人 2年前

感谢大佬解答。

你的答案

查看containerd相关的其他问题或提一个您自己的问题