How to list docker containers using runc
Asked Answered
E

1

5

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?

Exaggeration answered 11/5, 2020 at 20:41 Comment(0)
G
10

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

Gone answered 11/5, 2020 at 22:10 Comment(9)
Yes I saw this, but the post does not talk about finding this root directory.Exaggeration
I added one way to find it.Gone
root 1450 0.0 0.5 1307236 68028 ? Ssl Apr30 11:14 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sockExaggeration
Thats what I got, no --runtime-root in thereExaggeration
I noticed problem in there, it expected that docker was in path name, new updateGone
I have nothing like that on my system :'(Exaggeration
Seems like runtime-root parameter is specific for containerd-shim, and you don't have it running I guess?Gone
I just have docker installedExaggeration
I added two methods more, but there ends my knowledge.Gone

© 2022 - 2024 — McMap. All rights reserved.