How to SSH to docker container in kubernetes cluster?

For more recent Kubernetes versions the shell command should be separated by the --:

kubectl exec -it <POD NAME> -c <CONTAINER NAME> -- bash

Please note that bash needs to be availalble for execution inside of the container. For different OS flavours you might need to use /bin/sh, /bin/bash (or others) instead.

The command format for Kubernetes 1.5.0:

kubectl exec -it <POD NAME> -c <CONTAINER NAME> bash

List instances:

gcloud compute instances list

SSH into instance:

gcloud compute ssh <instance_name> --zone=<instance_zone>

In the instance, list the running processes and their container IDs:

sudo docker ps -a

Attach to a container:

sudo docker exec -it <container_id> bash