Is there any way to exec into an initContainer in Kubernetes

3/20/2019

I have a init container in which I'm storing file but while running it's showing the file is not present. Is there any way I can exec inside init container and check where the file is being stored.

-- Mukul Munjal
containers
docker
kubernetes

1 Answer

3/20/2019

Use kubectl describe <pod> to get the id of the initContainer you need to exec into then use kubectl exec -ti <pod> -c <container> sh to access its shell. You may need to add some kind of delay, like sleep to the initContainer to access it before it completes or fails.

-- kellanburket
Source: StackOverflow