user1726366
user1726366

Reputation: 2416

How to check other containers file systems within a k8s pod?

I have a Pod which contains two containers - nginx and busybox. Now I want to access the files within nginx container from the busybox container, say doing 'ls /etc/nginx' in busybox container to list the files there. Is there any configuration in k8s pod to allow me to achieve this?

Below is my current pod yaml file.

apiVersion: v1
kind: Pod
metadata:
  labels:
    run: nginxbusybox
  name: nginxbusybox
spec:
  shareProcessNamespace: true
  containers:
  - image: nginx
    name: nginx
  - image: busybox
    name: busybox
    command:
    - sleep
    - '86400'

P.S. This is for debugging a container which don't have the common linux tools within.

Upvotes: 0

Views: 1085

Answers (1)

user1726366
user1726366

Reputation: 2416

OK, I've found a way to achieve this. By using the 'kubectl debug' and checking the /proc/1/root/, I could see the filesystem in the nginx container. Below's what this looks like.

enter image description here

Upvotes: 3

Related Questions