问题
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?
回答1:
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 e.g:
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
来源:https://stackoverflow.com/questions/61738905/how-to-list-docker-containers-using-runc