How to inspect the contents of a container of a pod deployed with Kubernetes

6/20/2019

I run an .NET Core 2.1 in a container. It writes logs to a file within the container. I am able to run a docker exec bash command to inspect the log file, locally.

This application is then deployed with Kubernetes to a pod with more than one container.

How can I inspect the log file within each one of these containers?

-- user11081980
kubernetes

1 Answer

6/20/2019

You can exec into container within pod:

kubectl -n <namespace> exec -it <pod name> -c <container name> bash

But the better approach is to make your application stream logs to stdout or stderr, so you can access it directly with:

kubectl -n <namespace> logs <pod name> -c <container name> 
-- Adam Otto
Source: StackOverflow