当我使用 "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
命令有什么问题吗?
containerd默认命名空间的,如果是基于k8s的,默认命名空间是
k8s.io
,加上就可以了:ctr --namespace k8s.io containers ls
感谢大佬解答。
你的答案