Everything you learned about one container still works. You only have to say which one.
-c
text
learner@shallows:~$ kubectl logs shipped
error: a container name must be specified for pod shipped, choose one of: [web]
learner@shallows:~$ kubectl logs shipped -c log-shipper
shipping logs
learner@shallows:~$ kubectl exec shipped -c web -- ls /var/log/nginx| Command | With several containers |
|---|---|
kubectl logs POD -c NAME | One container's output; init containers and sidecars too |
kubectl logs POD --all-containers | Every container, one after another; --prefix labels the lines |
kubectl exec POD -c NAME -- CMD | Run inside one container |
Without -c, exec picks the first app container and says so: Defaulted container "web" out of: web, helper. logs refuses, because guessing which log you meant is worse.
describe breaks it down
kubectl get pods sums up a Pod: READY 1/2, RESTARTS 5. describe tells you which container:
text
Init Containers:
log-shipper:
State: Running
Ready: True
Restart Count: 0
Containers:
web:
State: Waiting
Reason: CrashLoopBackOff
Last State: Terminated
Reason: Error
Exit Code: 1
Ready: False
Restart Count: 5Each container has its own State, Last State, Ready and Restart Count. The Pod's Events at the bottom name the container too: Started container web, Back-off restarting failed container web.