Goglides Dev 🌱

Balkrishna Pandey
Balkrishna Pandey

Posted on

How to connect to one of the pods with bash?

You can connect to a pod using kubectl exec command. For example,


kubectl exec -it nginx-776567f984-vxdzw -- bash

Enter fullscreen mode Exit fullscreen mode

This will connect you to one of the pods with bash enabled.


root@nginx-776567f984-vxdzw:/# whoami

root

root@nginx-776567f984-vxdzw:/# hostname

nginx-776567f984-vxdzw

Enter fullscreen mode Exit fullscreen mode

A pod can run multiple containers and you need to specify which container you want to connect to. You can find the container name using kubectl describe pod nginx-776567f984-vxdzw | grep -i container command.

Top comments (0)