简体   繁体   中英

How to list docker containers using runc

From what I can tell runc list allows to pass a root directory for container storage. But I can't figure out what root directory to pass for docker. I tried /var/lib/docker/containers but it says container don't exist. I do have containers showing up in docker ps (fyi).

Or am I wrong in assuming that docker still uses runc to run containers?

EDIT: Based on Niklas's answer. Is there a way of finding root directories for runc - from docker or the scanning the file system?

Root directory is in different place. You could use

sudo runc --root /run/docker/runtime-runc/moby  list

One way for finding root directory is looking for init arguments:

 ps aux | grep runtime-root

Which should show argument for -runtime-root , and inside there are usually at least moby named directory, in case of Docker.

Second way is for looking Docker containerd configuration

/var/run/docker/containerd/containerd.toml

Where is default runtime_root

Third way, in case you have /etc/docker/daemon.json existing, there is place for runtime configuration.

Fourth way (Be careful with this one.). Get PID of containerd

Inspect process with strace and look for execve calls: sudo strace -f -e execve -p <PID>

Restart/start some container. And you might see some calls eg:

execve("/usr/sbin/runc", ["runc", "--root", "/var/run/docker/runtime-runc/mob"

More info: runc and ctr commands do not show docker images and containers

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM