Login to Container in Kubernetes

Step 0

Get all pods

kubectl get po --all-namespaces

Find the pod name in which your container is running

Step 1

Get the container name from running pod

kubectl describe po pod_name --namespace my_namespace

Example output

Name: pod_name
Namespace: my_namespace
Node: docker-host-03/
Start Time: Wed, 23 Nov 2016 16:57:15 +1100
Labels: name=my_container_name,pod-template-hash=2802333548
Status: Running

Note the label with value name

Step 2

Login to container


kubectl exec -it pod_name --namespace my_namespace -c my_container_name bash