What is the difference in privilege granted to a container in the following 2 scenarios
- sudo docker run -d --privileged --pid=host alpine:3.8 tail -f /dev/null
- Using kubernetes
apiVersion: v1
kind: Pod
metadata:
name: nsenter-alpine
spec:
hostPID: true
containers:
- name: nsenter-alpine
image: alpine:3.8
resources:
limits:
cpu: "500m"
memory: "200Mi"
requests:
cpu: "100m"
memory: "100Mi"
command: ["tail"]
args: ["-f", "/dev/null"]
securityContext:
privilege: true
in case 1)
/ # ps -ef | wc -l
604
in case 2)
[root@localhost /]# ps -ef | wc -l
266
Clearly when a privilege container is instantiated directly using docker then it is able to see processes of the host but when it is launched using kubernetes it can only see few of the processes. What is the reason behind it?