Tag Archives: docker/kubernetes

Error from server (BadRequest): a container name must be specified for pod

report errors

Previously, I used kubectl logs -f <POD-name> -n <nameSpace> to view the logs of a pod. One day when I used this command to check the status of a pod that was runnning, I got an error.

Error from server (BadRequest): a container name must be specified for pod xxx ,choose one of:[xxx  xxx]


Causes and treatment of error reporting

Reason: originally, a pod used a container. When you use the command to view the pod log, the log of the pod’s container will be output…
but one day, the architect adjusted the structure of the pod and enabled multiple containers in a pod. From then on, you need to specify which container to view the pod when viewing the log. You can use the command – C < container_ name> Specify that the name of the container that can be viewed is listed in the choose one of error message

 kubectl logs -f  <POD-name> -n <nameSpace> -c  <container_name>