user11081980
user11081980

Reputation: 3289

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

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?

Upvotes: 1

Views: 710

Answers (1)

Ottovsky
Ottovsky

Reputation: 2258

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> 

Upvotes: 2

Related Questions