0
root@k8scp:/proc/1328/cwd# ls -l /proc/1328/cwd
lrwxrwxrwx 1 root root 0 Jan 30 09:44 /proc/1328/cwd -> /

I looks like cwd is a symlink to the rhttps://serverfault.com/questions/1091636/containerd-proc-pid-cwd-is-a-symlink-to-but-thats-not-the-root-dir-of-the-noot directory.

Pid 1328 is a container of containerd of a kubernetes master node.

root@k8scp:~# grep PRETTY /etc/os-release /proc/1328/cwd/etc/os-release 

/etc/os-release:PRETTY_NAME="Ubuntu 20.04.3 LTS"
/proc/1328/cwd/etc/os-release:PRETTY_NAME="Distroless"

This confuses me, since this means that /proc/1328/cwd is not a normal symlink, but a magic thing pointing to the root directory of the container.

How can this be explained.

Up to now I thought a symlink is just a string which can be valid (or an sometimes invalid) path.

guettli
  • 3,591
  • 17
  • 72
  • 123

1 Answers1

1

/proc/PID/cwd, a symlink to the current working directory of the process. Containers are nothing but processes running in network namespaces.

https://web.mit.edu/rhel-doc/5/RHEL-5-manual/Deployment_Guide-en-US/s1-proc-directories.html

Rajesh Dutta
  • 306
  • 1
  • 5