38

Get easy access to container files via procfs

Read container files via procfs:

$ ps fax
[...]
24320 ?     Sl  1:26 /usr/sbin/containerd-shim-runc-v2 [...]
24341 pts/0 Ss+ 0:00  \_ /bin/bash /entry.sh
[...]

$ cat /proc/24341/root/entry.sh
#!/bin/bash
set -e
supervisord -c /etc/supervisord.conf

$ cat /proc/24341/root/etc/hostname
somecontainer

When inspecting containers, such as during a white-box audit, it is often helpful to quickly inspect files within a container. Instead of entering the container or copying the file in question, you can use the procfs on the host side to access any file.

The trick is that the /proc//root symlink translates into the container’s mount namespace. This means reading from /proc//root/foo will access /foo inside the container’s mount namespace.

Icon with a waving hand

Get in touch

sigma star gmbh
Eduard-Bodem-Gasse 6, 1st floor
6020 Innsbruck | Austria

sigma star gmbh logo