How-To Query Container Mounts Using Crictl or Nerdctl
Problem
You want to list the mounts from each container without needing to exec into the container.
Environment
- Platform9 Managed Kubernetes - All Versions
- Containerd
Procedure
- List the containers running on the node using the crictl or nerdctl utility pre-installed on the node.
x
# /opt/pf9/pf9-kube/bin/crictl -r unix:///run/containerd/containerd.sock ps
CONTAINER IMAGE CREATED STATE NAME ATTEMPT POD ID
68484121d71d1 0e9462c49c897 22 hours ago Running pf9-addon-operator 0 31ce653d2a519
# /opt/pf9/pf9-kube/bin/nerdctl -n k8s.io ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
62d00aca415d gcr.io/etcd-development/etcd:v3.4.14 "/usr/local/bin/etcd" 25 hours ago Up etcd
.
- Find the PID of the container
# /opt/pf9/pf9-kube/bin/crictl -r unix:///run/containerd/containerd.sock inspect --output go-template --template '{{.info.pid}}' <container_ID>
28389
# /opt/pf9/pf9-kube/bin/nerdctl -n k8s.io inspect <container_ID> --format '{{.State.Pid}}'
21129
- Query the /proc filesystem to find the mount information for each container.
# cat /proc/28389/mountinfo
749 656 0:169 / / rw,relatime master:116 - overlay overlay rw,seclabel,lowerdir=/var/lib/containerd/io.containerd.snapshotter.v1.overlayfs/snapshots/3360/fs:/var/lib/containerd/io.containerd.snapshotter.v1.overlayfs/snapshots/3359/fs:/var/lib/containerd/io.containerd.snapshotter.v1.overlayfs/snapshots/3358/fs:/var/lib/containerd/io.containerd.snapshotter.v1.overlayfs/snapshots/3277/fs:/var/lib/containerd/io.containerd.snapshotter.v1.overlayfs/snapshots/3276/fs,upperdir=/var/lib/containerd/io.containerd.snapshotter.v1.overlayfs/snapshots/3512/fs,workdir=/var/lib/containerd/io.containerd.snapshotter.v1.overlayfs/snapshots/3512/work
750 749 0:171 / /proc rw,nosuid,nodev,noexec,relatime - proc proc rw
751 749 0:172 / /dev rw,nosuid - tmpfs tmpfs rw,seclabel,size=65536k,mode=755
Was this page helpful?